-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Package
filament/filament
Package Version
v4.x.x
Laravel Version
v12.38.1
Livewire Version
v3.6.4
PHP Version
PHP 8.4.6
Problem description
When using disableOptionWhen() on a CheckboxList, validation fails for disabled options even though they are checked and submitted with the form.
The issue occurs because the validation only checks against enabled options, excluding any disabled ones. This causes the validation to reject values from disabled checkboxes that are legitimately selected and submitted.
Solution in my proyect
add
->in(fn (CheckboxList $component): array => array_keys($component->getOptions()))
Expected behavior
The documentation or examples should clarify that when validating a CheckboxList with disabled options, getOptions() should be used instead of getEnabledOptions() in the ->in() validation rule.
Steps to reproduce
- Create a CheckboxList form field with multiple options
- Use disableOptionWhen() to disable at least one option that will be checked
- Submit the form with the disabled option checked
- Observe that validation fails with the message: The form_items field is not in the list of allowed values.
use Filament\Forms\Components\CheckboxList;
CheckboxList::make('form_items')
->options([
'name' => 'Name',
'email' => 'Email',
'phone' => 'Phone',
])
->disableOptionWhen(fn (string $value): bool => $value === 'email');
Reproduction repository (issue will be closed if this is not valid)
https://github.com/liberty-technologies/managed-wifi
Relevant log output
Metadata
Metadata
Assignees
Labels
Type
Projects
Status