EditAction and ViewAction doesn't work on livewire-table

Hi everyone! I used a livewire-table to show different roles. I'm having issues with the EditAction and ViewAction: when I click on edit, the loader starts and, when finished, I get a "saved" notification. When I click on view, nothing happens. The wierd thing is that the DeleteAction works as intended. This is my code:
class RoleManager extends Component implements HasForms, HasTable, HasActions
{
...

public static function table(Table $table): Table
{
return $table
->query(Role::query())
->columns([
TextColumn::make('id')
->sortable(),
TextInputColumn::make('name')
->label('Nome del ruolo')
->searchable(),
TextColumn::make('description')
->label('Descrizione')
->searchable()
->toggleable(),
])
->reorderable('order')
->reorderRecordsTriggerAction(
fn (Action $action, bool $isReordering) => $action
->button()
->label($isReordering ? 'Conferma' : 'Riordina'),
)
->defaultSort('order')
->striped()
->filters([
//
])
->actions([
EditAction::make()
->label('Modifica'),
DeleteAction::make()
->label('Cancella'),
ViewAction::make(),

])
->bulkActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
])
->headerActions([
//
]);
}
...
}
class RoleManager extends Component implements HasForms, HasTable, HasActions
{
...

public static function table(Table $table): Table
{
return $table
->query(Role::query())
->columns([
TextColumn::make('id')
->sortable(),
TextInputColumn::make('name')
->label('Nome del ruolo')
->searchable(),
TextColumn::make('description')
->label('Descrizione')
->searchable()
->toggleable(),
])
->reorderable('order')
->reorderRecordsTriggerAction(
fn (Action $action, bool $isReordering) => $action
->button()
->label($isReordering ? 'Conferma' : 'Riordina'),
)
->defaultSort('order')
->striped()
->filters([
//
])
->actions([
EditAction::make()
->label('Modifica'),
DeleteAction::make()
->label('Cancella'),
ViewAction::make(),

])
->bulkActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
])
->headerActions([
//
]);
}
...
}
I also tried to use the getPages method from the resource. Thank you so much for the help.
1 Reply
Davide Cariola
Davide CariolaOP14mo ago
Hi guys, for everyone that had or will have the same problem, I found a solution. Here's the code to put in your $table actions method:
use Filament\Tables\Actions\Action;


->actions([
Action::make('edit')
->url(fn (Role $record): string => RoleResource::getUrl('edit', ['record' => $record])),
])
use Filament\Tables\Actions\Action;


->actions([
Action::make('edit')
->url(fn (Role $record): string => RoleResource::getUrl('edit', ['record' => $record])),
])
Table Actions can access to the selected record. With the getUrl() method, you can generate any URL regarding the resource, without the necessity to create a specific Laravel route. You can find it here in the docs: https://filamentphp.com/docs/3.x/panels/resources/getting-started#generating-urls-to-resource-pages
Want results from more Discord servers?
Add your server