I'm trying to customize the way a record is created. So, in the CreatePage
of my resource, I have:
protected function handleRecordCreation(array $data): Model
{
// Here I want to access to the data coming from the main form AND from the form in the modal ('how_many' field)
// $data DOES NOT contains "how_many"
}
protected function getCreateFormAction(): \Filament\Actions\Action
{
return \Filament\Actions\Action::make('create')
->label(__('filament-panels::resources/pages/create-record.form.actions.create.label'))
->requiresConfirmation()
->form([
Select::make('how_many')
->label(__('site.howMany'))
->options(collect(range(1, 20))->mapWithKeys(fn($number) => [$number => $number])),
])
->modalDescription('Desc')
->action(function (CreateAnimal $livewire, array $data) {
$livewire->data = array_merge($livewire->data, $data); // HERE $livewire->data contains "how_many"
$livewire->create();
})
->keyBindings(['mod+s']);
}
As mentioned in the comments, I would like to access the value of how_many
in the method handleRecordCreation
.
How could I do that ?
Thank you for your help.