F
Filament•2mo ago
Grégoire

Validating multi-select fields

Hey, How would you properly validate the options for a multi-select field in Livewire? While it works well without the multiple attribute, the validation doesn't seem to be applied when it is added. Adding in doesn't seem to help either. What am I missing?
Select::make('languages')
->multiple()
->options([
'en' => 'English',
'es' => 'Spanish',
'fr' => 'French',
])
Select::make('languages')
->multiple()
->options([
'en' => 'English',
'es' => 'Spanish',
'fr' => 'French',
])
livewire(AppSettings::class)
->fillForm([
'languages' => ['klingon'],
])
->call('save')
->assertHasFormErrors(['languages']); // Failed asserting that false is true.
livewire(AppSettings::class)
->fillForm([
'languages' => ['klingon'],
])
->call('save')
->assertHasFormErrors(['languages']); // Failed asserting that false is true.
1 Reply
Grégoire
GrégoireOP•2mo ago
🆙 I am still facing the issue, would love to have your opinion.

Did you find this page helpful?