disabled option items in a select list are treated as empty by jquery validation

Created on 24 January 2024, over 1 year ago

Problem/Motivation

We have a select list field that has multiple items and is a required field. Some items are disabled for certain roles. We have a safety built in so that if it is disabled for a certain editor, the disabled item remains selected so that there is not a data loss when the editor saves the node. Even though the item in the list has a value and is selected, jquery validation prevents the form from being submitted because it claims the field is empty.

        <select class="menu-parent-select form-select required form-element form-element--type-select" data-drupal-selector="edit-menu-menu-parent" id="edit-menu-menu-parent" name="menu[menu_parent]" required="required" aria-required="true">
<option value="0">- Select a value -</option>
<option value="va-lebanon:">&lt;VA Lebanon health care&gt;</option>
<option value="va-lebanon:menu_link_content:ebc72ab1-43bd-4125-ac60-3c8762b970ea">-- VA Lebanon health care</option>
<option value="va-lebanon:menu_link_content:9e1b7d74-cbc2-4484-abad-71c863a14bf3">---- Billing and Insurance (disabled)</option><option value="va-lebanon:menu_link_content:3a4433b2-e4c7-4af5-b5b7-b744edd7363d">---- Billing and insurance (disabled)</option><option value="va-lebanon:menu_link_content:83d78804-4a5d-4282-bb0e-a112a882906a">------ Stories</option>
<option value="va-lebanon:menu_link_content:32967323-5980-4b5c-8424-a5b002bc8f47">------ About us</option>
<option value="va-lebanon:menu_link_content:a6cbeefe-4213-40d9-ae20-593f95f9cbcf" selected="selected">------ Work with us</option><option value="va-lebanon:menu_link_content:a3c56b5c-96d8-409c-a99b-f8173a99c2fc">-------- Jobs and careers</option><option value="va-lebanon:menu_link_content:a2276ef0-d4e2-41ef-9baf-cc2ac0341a46">---------- Lebanon VA Nursing Careers</option><option value="va-lebanon:menu_link_content:b948da19-2237-4519-96cb-d114f07cfe32">------------ Lebanon VA Behavioral Health</option>

Despite being selected, "Work with us" is prevented from being saved with the claim that it is not allowed to be empty.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

4.0

Component

Form Validation

Created by

πŸ‡ΊπŸ‡ΈUnited States swirt Florida

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024