Skip to content

Disabled field fails validation in CheckboxList #18516

@JoelChoy0

Description

@JoelChoy0

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

  1. Create a CheckboxList form field with multiple options
  2. Use disableOptionWhen() to disable at least one option that will be checked
  3. Submit the form with the disabled option checked
  4. 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

No one assigned

    Type

    Projects

    Status

    Todo

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions