Lifecycle hooks not working in Edit function, Filament resource

32 Views Asked by At

I have a resource in a php Filament App called LoadResource. The standard out of the box Edit action on this resource is working fine - it however does not respond to any lifecycle hooks that I place in the Edit action statement.

My Edit Action is listed below:

->actions([
                Tables\Actions\ActionGroup::make([
                    Tables\Actions\ViewAction::make(),
                    EditAction::make()
                        ->before(function () {
                            dd('test');
                        }),
                    Tables\Actions\DeleteAction::make(),
                ])
            ])

I am using the following:

use Filament\Actions\EditAction;

I however never get to the function within the beforeFormFilled() closure. Any ideas to assist would be greatly appreciated.

Was expecting the function in the beforeFormFilled() to run.

I tried to place the lifecycle hook on the Edit page of the Resource - that worked. However, I dont know how to reference the model from the Edit page $this-> references the Edit page, not the form or the model. When I try to pass the model to the Edit page, I get an error.

For reference, the following does work - with the hassles mentioned above:

protected function beforeSave (array $data): void
    {

        dd($data);
    }
0

There are 0 best solutions below