F
Filament12mo ago
KingNii

How can I get data from the form in actions?

Action::make('edit') // ->requiresConfirmation() ->form([ TextInput::make('name'), TextInput::make('price'), TextInput::make('slug'), // TextInput::make('category'), Select::make('category') ->label('Category') ->options(Products::all()->pluck('name', 'id')) ->searchable(), TextInput::make('description'), FileUpload::make('image_url'), ]) ->fillForm(fn (Products $record): array => [ 'name' => $record->name, 'price' => $record->price, 'slug' => $record->slug, 'category' => $record->category->id, 'description' => $record->description, ]) ->action(function (Products $record): void { // dd($record); dd($this->form->getState()); $record->update($this->form->getState()); // $record->approve(); })
3 Replies
KingNii
KingNiiOP12mo ago
Estevão Simões
Estevão Simões12mo ago
Have you tried passing in array $data?
->action(function (Products $record, array $data)
->action(function (Products $record, array $data)
KingNii
KingNiiOP12mo ago
@Estevão Simões its solved. Just marked this post solved. thank you.
Want results from more Discord servers?
Add your server