0

I have created 2 radio buttons. When i select 1 radio button, then represented field has to display and hide other field represented to next radio button. When I select radio1, only textfield1 has to display and radio2, only textfield2 has to display. enter image description here

2
  • This can be done with Jquery easily. What are you looking for in Drupal ? A module ?
    – GoodSp33d
    Commented Aug 27, 2012 at 9:51
  • Kantu@ What ever it may be..jquery or php..These fields are in my new content type..
    – Srinu
    Commented Aug 27, 2012 at 9:53

2 Answers 2

6

This could also be done by using states that are available in Drupal core. For example you could set that an element in a form should only be visible if another element has the value "x".

    $form['my_element']['#states'] = array(
      'visible' => array(
        ':input[name="some_other_element"]' => array('value' => 'some_value_that_has_to_be_set'),
      ),
    );

More examples at form_example_states_form.

You can add states to elements in an implementation of hook_form_alter or add it directly to the form if you are programming it yourself.

2

Use the Conditional fields module:

Conditional Fields allows you to manage sets of dependencies between fields. When a field is “dependent”, it will only be available for editing and displayed if the state of the “dependee” field matches the right condition.

2
  • Nik, Pls see updated question with image...
    – Srinu
    Commented Aug 27, 2012 at 9:44
  • Can we write by enabling php filter while creating radio boxes?
    – Srinu
    Commented Aug 27, 2012 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.