CheckboxList ->in() validation not working

Hey, Using what's on the docs I have the following code with different values:
CheckboxList::make('technologies')
->options([
'tailwind' => 'Tailwind CSS',
'alpine' => 'Alpine.js',
'laravel' => 'Laravel',
'livewire' => 'Laravel Livewire',
'heroicons' => 'SVG icons',
])
->in(fn (CheckboxList $component): array => array_keys($component->getEnabledOptions()))
CheckboxList::make('technologies')
->options([
'tailwind' => 'Tailwind CSS',
'alpine' => 'Alpine.js',
'laravel' => 'Laravel',
'livewire' => 'Laravel Livewire',
'heroicons' => 'SVG icons',
])
->in(fn (CheckboxList $component): array => array_keys($component->getEnabledOptions()))
When using the in validation rule and calling getState the field returns an error "is invalid" When removing this rule I have no errors and every other fields are working as expected Worth noting that I have radios with the same code and those are working as expected Thx for any help!
4 Replies
skyrowl
skyrowlOP2mo ago
found out that CheckboxList is not considered an array until adding a rule related to arrays as such as ->minItems(1) I probably should open an issue but don't really know how to fix this rn
Busk
Busk2mo ago
Just ran into this issue too. Seems like a Laravel thing to only consider it an array if an array related rule is added. Wow
toeknee
toeknee2mo ago
Did you cast the value to an array?
skyrowl
skyrowlOP2mo ago
yeah I did, problem is in validation rules I dumped them and it missed the array rule
Want results from more Discord servers?
Add your server