<?php
// sample code
/**
* Implementation of hook_form_FORM_ID_alter()
*/
function demo_form_sport_node_form_alter(&$form, &$form_state, $form_id) {
   
$form['field_winter_sports'] = array(
   
'#states' => array(
       
'visible' => array(   // action to take.
           
':input[name=field_season]' => array('value' => t('winter')),
        ),
    ),
);
}
?>

i am trying to alter a form from a "sport" node type. my "sport" node type has 2 fields.

field_season List (text) Check boxes/radio buttons
field_winter_sports List (text) Check boxes/radio buttons
there are two options in field_season, summer or winter.

if someone selects winter in field_season, i want to make field_winter_sports visible, otherwise remain hidden.

with my current code, when i select winter right now, nothing happens.

Comments

There are certain contributed modules available which matches your requirement, you can might have a look :
https://drupal.org/project/conditional_fields
https://drupal.org/project/field-conditional-state
https://drupal.org/project/select_or_other

Its just a thought might help you out.

Abhishek Sawant
Drupal Developer

Don't know if you've figured this out already, but you forgot the quotes for the input name. It should be like this:

<?php
':input[name="field_season"]' => array('value' => t('winter')),
?>

Hope it helps....

Shabana Navas
Drupal Developer
Blackborder