Edit Action

how to disable edit action if form field have some value ??
4 Replies
LeandroFerreira
Why not a field validation? If the form contains errors, you can't submit it
negro
negro2w ago
It's not what I need I have a toggle field in my form the default value is false and only display on edit. If you set this value to true I don't want to edit the form again
Tetracyclic
Tetracyclic2w ago
Do you mean hiding the Edit action on the table view for any records that have that field set to true? If so, you can use either the visible(), hidden() or disabled() method on the EditAction. You can pass it a closure that accepts the $record, and return the state of that field:
Action::make('edit')
->hidden(fn ($record): bool => $record->your_field)
Action::make('edit')
->hidden(fn ($record): bool => $record->your_field)
Action::make('edit')
->disabled(fn ($record): bool => $record->your_field)
Action::make('edit')
->disabled(fn ($record): bool => $record->your_field)
negro
negro2w ago
thanks you it works