Using #states to disable a field collection field I am trying to disable a date field's second value, inside a field collection, but it isn't working.

My hook_form_alter has this:

  $form['field_certification']['und'][0]['field_validity']['und'][0]['#states'] = array(
        'disabled' =&gt; array(
          'input[name="field_certification[und][0][field_auto_calculate_validity][und]"]' =&gt; array('checked' =&gt; TRUE),
        ),
      );


The HTML for the date field is here:

&lt;input class="date-clear form-text hasDatepicker date-popup-init" type="text" id="edit-field-certification-und-0-field-validity-und-0-value2-datepicker-popup-0" name="field_certification[und][0][field_validity][und][0][value2][date]" value="07/23/2014" size="20" maxlength="30"&gt;


The checkbox is here:

&lt;input type="checkbox" id="edit-field-certification-und-0-field-auto-calculate-validity-und" name="field_certification[und][0][field_auto_calculate_validity][und]" value="1" class="form-checkbox"&gt;


Could it be because I'm not specifically selecting the (second) value of the date field?
My original answer totally missed the point (apologies), this is updated version:

I do not think you can use Drupal's form api #state property to accomplish what you would like. States can be used to hide, reveal and disable whole form elements, such as a fieldset, text input or date field, but you aim to disable one part of a single (contrib) element (ie the second value of a date_combo field provided by the date module).

There are two possible solutions:


load your own jquery when the form is loaded, and add a change() function to disable the relevant date field component
separate the start/end dates into separate date fields and use the drupal #states functionality (as above) to disable the (whole) second date field:

$form['field_certification']['und'][0]['field_validity']['#states'] = array(
'disabled' =&gt; array(
    ':input[name="field_certification[und][0][field_auto_calculate_validity][und]"]' =&gt; array(
        'checked' =&gt; true
    ),
)


);


I hope this helps, I played around with it on a blank d7 install, and this was the only way I could get your intended functionality to work.