There are two things to consider:
The name of the input element is visible in the HTML output of the page, and that could not match with the ID used for that form element from the form API. That happens with form elements created with the field API too.
I created a field_season
field, which allows just a value to be select (which means it is rendered with radio buttons); the input element name that appears in the HTML output, which is the one jQuery sees, is field_season[und]
, not field_season
.

If I change the field to allow three choices (which means the form field is rendered as checkboxes), the input element name changes to field_season[und][1]
, field_season[und][2]
, and field_season[und][3]
.


When you want to tell to Drupal to alter the state of a form element when a radio buttons are used, you should not use t()
, and the string to use as value in the state is not the string that appears to the users, but the value assigned to the value attribute of the <input type="radio">
tag. For example, for the form element added from the following code, those values are 0, 1, and 2.
$form['registration_cancellation']['user_register'] = array(
'#type' => 'radios',
'#title' => t('Who can register accounts?'),
'#default_value' => variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL),
'#options' => array(
USER_REGISTER_ADMINISTRATORS_ONLY => t('Administrators only'),
USER_REGISTER_VISITORS => t('Visitors'),
USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL => t('Visitors, but administrator approval is required'),
),
);

Since the input element name contains und, which is the string value for the LANGUAGE_NONE
constant, I suspect the input element name could change basing on the language associated with the field, even if I suspect it would always be und, for radio buttons and checkboxes.
As side note, learningxm is correct when it says that you should use `:input[name=""]' since that is what the example in the drupal_process_states() page shows.
$form['toggle_me'] = array(
'#type' => 'checkbox',
'#title' => t('Tick this box to type'),
);
$form['settings'] = array(
'#type' => 'textfield',
'#states' => array(
// Only show this field when the 'toggle_me' checkbox is enabled.
'visible' => array(
':input[name="toggle_me"]' => array('checked' => TRUE),
),
),
);
As noted by Clive, you are overriding the form element added using the field API; to change the states associated with the form element, you should just use the following code.
$form['field_winter_sports']['#states'] = array(/** Add here your states. **/);
I assume field_winter_sports
is the correct form element ID.
I would also investigate using hook_field_widget_form_alter(), which is the hook thought to alter the form elements used for a field.