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?
7 Replies
ganucoding
ganucoding8mo ago
Or maybe currently Filament just doesn't support wire:model.blur
LeandroFerreira
LeandroFerreira8mo ago
use live()
otm
otm8mo ago
I have similar issue ,i have used live()
LeandroFerreira
LeandroFerreira8mo ago
What issue? Could you share the code please?
Adnan Yalahow
Adnan Yalahow6mo ago
please share the code
otm
otm6mo ago
the Solution @Leandro Ferreira suggested did the trick. the the code is Select::make('users') ->label('Users:') ->multiple() ->options([ 'test1' => 'Test One', 'test2' => 'Test Two', 'test3' => 'Test Three' ]) ->searchable() ->live() ->afterStateUpdated(function (Model $record, $state) { $record->update(['users' => $state]); }), sometimes it is good to clear the cache php artisan cache:clear
Yacoub Al-haidari
Did you solve this issue ?