Select multiple - fill

Is there a way to fill the field and its shows the updated select options?

Im using a filament form on a livewire component, and that form e a wizard, on the first step and user input a value and consult a api to prefill the data on the next steps, i can already fill all the data

with this

$this->form->fill([
'company' => [
'slug' => $company['seo_url'],
'name' => $company['title'],
'email' => $company['contacts']['email'],
'telefone' => $company['contacts']['phone'],
'address' => $company['address'],
'zip_code' => $company['pc4'].'-'.$company['pc3'],
'city' => $company['city'],
'caecodes' => collect($company['cae'] ?? [])
->filter()
->map(fn ($code) => (int) $code)
->values()
->all(),
],

and this is the select
Select::make('company.caecodes')->columnSpan(12)->multiple()
->relationship(name: 'caeCodes', titleAttribute: 'title')
->afterStateHydrated(
function (array $state) {
ray($state);
}
)


but the problem is that caecodes is a multi-select, i can see that the array is beeing filled, but the select does not update to show the values from the array as selected, if i select a new one its deletes the ones added from fill and keeps only the one from the from input

is there anyway to make the select show the values set by the form fill?

thanks
Was this page helpful?