F
Filament14mo ago
Matthew

How can I set the default value of a Select, when its hidden?

Select::make('status')
->label('Status')
->options(Status::all()->pluck('name', 'id'))
->searchable()
->default(Status::where('name', 'Pending')->first()->id)
->hiddenOn(['create','edit']),
// ->hiddenOn('create',),
// ->disabled(!auth()->user()->can('status_expense')),
Select::make('status')
->label('Status')
->options(Status::all()->pluck('name', 'id'))
->searchable()
->default(Status::where('name', 'Pending')->first()->id)
->hiddenOn(['create','edit']),
// ->hiddenOn('create',),
// ->disabled(!auth()->user()->can('status_expense')),
It shows up as null on the table
4 Replies
Dennis Koch
Dennis Koch14mo ago
Sure. It's not on the page. If you still need a value use one of the mutation methods.
Matthew
Matthew14mo ago
How do you mean?
Matthew
Matthew14mo ago
This worked! Thank you
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['status'] = Status::where('name', 'Pending')->first()->id;

return $data;
}
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['status'] = Status::where('name', 'Pending')->first()->id;

return $data;
}
Want results from more Discord servers?
Add your server
More Posts