Get data from confirmation modal form #15477
Replies: 2 comments
-
Hi again, I tried to dig deeper, and here is the current state of my "workaround" (though there are a lot of trade-offs): protected function getCreateFormAction(): Action
{
return parent::getCreateFormAction()
->label(__('filament-panels::resources/pages/create-record.form.actions.create.label'))
->modalDescription(__('animal.multipleCreationDescription'))
->requiresConfirmation(true)
->submit(null)
->form([
Select::make('how_many')
->label(__('site.howMany'))
->hiddenLabel()
->columnSpanFull()
->default(1)
->required()
->native(false)
->options(collect(range(1, 20))->mapWithKeys(fn($number) => [$number => $number])),
])
->keyBindings(['mod+s'])
->action(function ($livewire, $data) {
$howMany = $data['how_many'];
$formData = $livewire->data;
for ($i = 0; $i < $howMany; $i++) {
if (static::getModel()::createModel($formData)) {
Notification::make()
->title('Success')
->success()
->send();
} else {
Notification::make()
->title('Error')
->error()
->send();
}
}
});
} First, I had to create a Additionally, in the main form, I have Any insights or suggestions would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
-
The problem I am trying to solve is: is the a way to create multiple records when submitting the create form (and ask the use how many copies he wants)? |
Beta Was this translation helpful? Give feedback.
-
Package
Form builder
Package Version
v3.2
How can we help you?
Hi,
I'm trying to customize the way a record is created. So, in the
CreatePage
of my resource, I have:As mentioned in the comments, I would like to access the value of "
how_many
" in the methodhandleRecordCreation
.How could I do that ?
Thank you for your help.
Beta Was this translation helpful? Give feedback.
All reactions