Skip to content

[Feature] Support "disabled" state for individual select options in the admin config #40564

@rybkinevg

Description

@rybkinevg

Description

Currently, the Select, Multiselect and EditableMultisect form elements only supports the disabled attribute at the select element level, which disables the entire dropdown. There is no way to disable individual <option> elements within the select dropdown.

The current option properties supported are: label, value, title, and style. The feature request is to add support for a disabled property that can be passed from the source model to disable specific options while keeping others selectable.

Expected behavior

Support for a disabled key in the option array that accepts a boolean value (true/false)

Benefits

  • Better UX: Allows developers to show unavailable options in dropdowns while keeping them visible for context, rather than hiding them completely or disabling the entire select element
  • Standard HTML5 Compliance: The disabled attribute on <option> elements is part of the HTML5 standard and is widely supported across browsers
  • No Breaking Changes: The feature is additive and maintains full backward compatibility with existing code
  • Cleaner Conditional Logic: With native disabled support, conditional option availability can be handled directly in the source model with simple boolean logic, reducing JavaScript dependencies and improving maintainability

Additional information

Example:

public function toOptionArray(): array
{
    return [
        [
            'value' => 'default',
            'label' => __('Default'),
            'disabled' => true,
        ],
    ];
}

Release note

No response

Metadata

Metadata

Type

No type

Projects

Status

Pull Request in Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions