If we used #disabled & #states with disabled option on same element, then #states with disabled getting priority over form api #disabled. Which results in client side the field is not showing disabled.

  $form['name'] = array(
  '#type' => 'textfield',
  '#title' => t('Name'),
  '#states' => array(
       'disabled' => array(':input[name = "xyz"]' => array('checked' => TRUE ), ),
    ),
  '#disabled' => TRUE ,
  '#default_value' => 'me',
  );

I have checked on server side the default value what i set is get after submit. This means even you changed the form value it will not get on server side. It works as per form API. Problem is on client side only.

Comments

amar.deokar’s picture

Category: Support request » Bug report

Version: 7.34 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.