Handle the creation process for a wizard form

I've created a form with a Wizard but it doesn't 100% reflect the structure of my DB. For example, I have a fairly complex repeater for creating products, and I'd like to store the field values in a Json in my “products” table. Where I'm stuck is that I have no idea how to intercept the form's submit in order to process the data myself and insert it into my DB. So I created a submit action button using this method: https://filamentphp.com/docs/3.x/forms/layout/wizard#rendering-a-submit-button-on-the-last-step And then what do I do to process the submit? I found this: https://filamentphp.com/docs/3.x/panels/resources/creating-records#customizing-the-creation-process in the documentation. I've added the method to my resource file, but it doesn't seem to be called when I click on the "submit" button. Is there a particular method to use when on a Wizard? I can't find much Thanks in advance 😇
Solution:
handleRecordCreation is available in the CreatePage.php, not the resource class
Jump to solution
5 Replies
Alexandre
Alexandre3mo ago
Ah uh, sorry... When I mentioned my resource file, I meant the one at the root of app/Filament (in my case: RequestResource.php). I use the standard form() function.
public static function form(Form $form): Form {
return $form
->schema([
Wizard::make([ ...]);
->submitAction(new HtmlString(Blade::render(<<<BLADE
<x-filament::button
type="submit"
size="sm"
>
Submit
</x-filament::button>
BLADE
)))
]);
}

protected function handleRecordCreation(array $data): Model {
dd($data);
}
public static function form(Form $form): Form {
return $form
->schema([
Wizard::make([ ...]);
->submitAction(new HtmlString(Blade::render(<<<BLADE
<x-filament::button
type="submit"
size="sm"
>
Submit
</x-filament::button>
BLADE
)))
]);
}

protected function handleRecordCreation(array $data): Model {
dd($data);
}
Solution
LeandroFerreira
LeandroFerreira3mo ago
handleRecordCreation is available in the CreatePage.php, not the resource class
Alexandre
Alexandre3mo ago
Ah ok, I feel like an idiot... 🫥 Well, problem solved 😎
Thanks a lot for your time!
LeandroFerreira
LeandroFerreira3mo ago
You aren't an idiot, it is just a detail 👍