Show table actions on view page instead of edit page.

What I am trying to do: Currently my CreateAction button is only shown on the relationship table when editing the parent record. I want to show this button when viewing the parent record. What I did: I currently only found one solution and that is to add the ->authorize() method on the action. My issue/the error: I want to know if there is a (general) setting to show the buttons on the view page instead of the edit page. Code:
public function table(Table $table): Table
{
return $table
->headerActions([
CreateAction::make()
->authorize('create'),
])
->recordActions([
EditAction::make(),
DeleteAction::make(),
]);
}
public function table(Table $table): Table
{
return $table
->headerActions([
CreateAction::make()
->authorize('create'),
])
->recordActions([
EditAction::make(),
DeleteAction::make(),
]);
}
Solution:
Seems like this is the right solution: ->readOnlyRelationManagersOnResourceViewPagesByDefault(false); https://filamentphp.com/docs/4.x/resources/managing-relationships#read-only-mode...
Jump to solution
2 Replies
TDDeveloper
TDDeveloperOP4w ago
Seems like this works:
public function isReadOnly(): bool
{
return false;
}
public function isReadOnly(): bool
{
return false;
}
Is it recommended to do it this way?
Solution
TDDeveloper
TDDeveloper4w ago
Seems like this is the right solution: ->readOnlyRelationManagersOnResourceViewPagesByDefault(false); https://filamentphp.com/docs/4.x/resources/managing-relationships#read-only-mode

Did you find this page helpful?