最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - FilamentPHP: form in confirmation modal when creating record - Stack Overflow

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论