FilamentF
Filament3y ago
Vp

How to auto fill multiple select in Action

I have added new button and it contains multiple select, How can I make the select field auto display the name in EDIT

Tables\Actions\Action::make('link-account')
->mountUsing(
function (Forms\ComponentContainer $form, Customer $record) {
$childCustomer = Customer::where('approver', $record->id)->pluck('id');

$form->fill([
'approver_id' => $record->id,
'name' => $record->name.' ('.$record->idd.' '.$record->phone_number.')',
'child' => $childCustomer,
]);
}
)
->form([
Forms\Components\Hidden::make('approver_id'),
Forms\Components\TextInput::make('name')
->label(('Approver'))
->disabled(),

Forms\Components\Select::make('child')
->label(
('Child'))
->multiple()
->options(Customer::query()->active()->pluck('name', 'id'))
->searchable()
->required(),
])
->action(function (array $data): void {
dd($data);
}),

If it's empty then it working fine, but for edit the problem come like it diplay the ID in multi select field, not name... and in dd($data) action it comes the name, not ID

Sorry for bad english
Was this page helpful?