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
Have you tried passing in array $data?
@Estevão Simões its solved. Just marked this post solved. thank you.