Disable entire form - throws error when checking $operation

I want to disable my edit form when certain criteria are met.
I don't want to do it on a field by field basis as this is a fairly large and complex form (also why I don't want a view). Snippet from my resource:
public static function form(Form $form): Form
{
return $form
->disabled(fn (?Quote $record, string $operation): bool => $operation == 'edit' && $record->status == 'final')
->schema([])
public static function form(Form $form): Form
{
return $form
->disabled(fn (?Quote $record, string $operation): bool => $operation == 'edit' && $record->status == 'final')
->schema([])
But this throws An attempt was made to evaluate a closure for [Filament\Forms\Form], but [$operation] was unresolvable. https://flareapp.io/share/17DXjr67 I thought the $operation helper was globally available Small caveat - I've rushed my dog to the vets 3 times in the last 7 days so I'm a bit emotionally frazzled - I'm sure the answer is blindingly obvious nbl
Flare
An attempt was made to evaluate a closure for [Filament\Forms\Form], but [$operation] was unresolvable. - The error occurred at https://f2t.test/admin/quotes/1/edit
Solution:
->disabled(fn (?Quote $record): bool => $record !== null && $record->status == 'final')
Jump to solution
3 Replies
toeknee
toeknee5mo ago
Beause operation doesn't exist on disabled method/
Blackpig
BlackpigOP5mo ago
Yep, I adjusted to check for the record existence instead
Solution
Blackpig
Blackpig5mo ago
->disabled(fn (?Quote $record): bool => $record !== null && $record->status == 'final')
Want results from more Discord servers?
Add your server