ganucoding
ganucoding
FFilament
Created by ganucoding on 11/28/2023 in #❓┊help
Why Select multiple & TagsInput afterStateUpdated() not triggering
- I'm trying to wire:model.blur my users field using Select()->multiple()->options([])->live(onBlur: true)->afterStateUpdated(). - I tried live(onBlur: true)->afterStateUpdated() using other input like TextInput, Select (single option), Radio. And those inputs work just fine. - Example of working code (using TextInput): when I un-focus the name field, it will run the afterStateUpdated method and save the updated data in db.
TextInput::make('name')
->label('Name:')
->live(onBlur: true)
->afterStateUpdated(function (Model $record, ?string $state) {
$record->update(['name' => $state]);
}),
TextInput::make('name')
->label('Name:')
->live(onBlur: true)
->afterStateUpdated(function (Model $record, ?string $state) {
$record->update(['name' => $state]);
}),
- NOT WORKING: afterStateUpdated method not even triggered, when I select/deselect. Nothing seems to work.
Select::make('users')
->label('Users:')
->multiple()
->options([
'test1' => 'Test One',
'test2' => 'Test Two',
'test3' => 'Test Three'
])
->searchable()
->live(onBlur: true)
->afterStateUpdated(function (Model $record, $state) {
$record->update(['users' => $state]);
}),
Select::make('users')
->label('Users:')
->multiple()
->options([
'test1' => 'Test One',
'test2' => 'Test Two',
'test3' => 'Test Three'
])
->searchable()
->live(onBlur: true)
->afterStateUpdated(function (Model $record, $state) {
$record->update(['users' => $state]);
}),
Any suggestions?
9 replies