F
Filament4mo ago
kaziux

I can't reach out form multi select data in filament v3

Hello while I'm using Livewire and Filament v3 wizard form on the top of it. I 'm using multi select but I have issue I can't access multi select data properties. When I'm dumping they aren't at all.
8 Replies
awcodes
awcodes4mo ago
Share some code.
kaziux
kaziuxOP4mo ago
return $form
->schema([
Wizard::make([
Wizard\Step::make('Info')
->schema([
Hidden::make('client_id')
->default(fn() => Auth::id())
->dehydrated(),
... some properties
Select::make('categories')
->label('Categoreis')
->multiple()
->relationship('categories', 'title')
->required()
->preload()
->searchable(),
Select::make('tags')
->label('Tags')
->multiple()
->relationship('tags', 'title')
->preload()
->searchable()
.... some properties
])>afterValidation(function () {
$data = $this->form->getState();
dump($data); // There aren't multiselect properties, despite values are shown being set in the debugbar livewar tab
dd($data['categories']);
})
return $form
->schema([
Wizard::make([
Wizard\Step::make('Info')
->schema([
Hidden::make('client_id')
->default(fn() => Auth::id())
->dehydrated(),
... some properties
Select::make('categories')
->label('Categoreis')
->multiple()
->relationship('categories', 'title')
->required()
->preload()
->searchable(),
Select::make('tags')
->label('Tags')
->multiple()
->relationship('tags', 'title')
->preload()
->searchable()
.... some properties
])>afterValidation(function () {
$data = $this->form->getState();
dump($data); // There aren't multiselect properties, despite values are shown being set in the debugbar livewar tab
dd($data['categories']);
})
awcodes
awcodes4mo ago
Relationships are typically handled automatically so if you need to do anything based on the relationship then $this->form->getRawState() will give you the values. Just be aware that raw state happens before any validation.
kaziux
kaziuxOP4mo ago
It's using full filament resource page forms, but this case I'm using on the top of livewire component
awcodes
awcodes4mo ago
Right but the trait still has both form->getState() which is after validation and ->getRawState() which is before validation. Relationships are handled between the two. So if you need to do something based on the relationship, getState() is too late in the lifecycle.
kaziux
kaziuxOP4mo ago
mandatory validated field should be handled and be accessible but my form has both mandatory and non-mandatory fields
awcodes
awcodes4mo ago
Well, try the ->getRawState() use some dd’s then get back to us.
kaziux
kaziuxOP4mo ago
Bingo, I can access full form with getState multi select fields aren't accessible regardles of mandatory status dehydartion trick help to get form data with getState

Did you find this page helpful?