Displaying follow up fields for a content type I have a form that asks the user to answer several yes or no health questions. These questions are radio button widgets and what I've been trying to do is ask the user to fill out a follow up question, a text area which should be invisible until when the user selects the 'Yes' radio button. I have one method which involved some Javascript, but my I'm mostly a backend developer so I'm really struggling. 

Anyone know how I can do this?
Drupal 7 introduced the #states property for form elements. It:


  Adds JavaScript to the element to allow it to have different active states.


Here's a short example that applies to your use case:

function MYMODULE_my_form($form, &amp;$form_state) {
  $form['my_radios'] = array(
    '#type' =&gt; 'radios',
    '#title' =&gt; 'Radios',
    '#options' =&gt; array('no' =&gt; 'No', 'yes' =&gt; 'Yes'),
    '#default_value' =&gt; 'no'
  );

  $form['textarea'] = array(
    '#type' =&gt; 'textarea',
    '#title' =&gt; 'Textarea',
    '#states' =&gt; array(
      'visible' =&gt; array(
        ':input[name="my_radios"]' =&gt; array('value' =&gt; 'yes')
      )
    )
  );

  return $form;
}


The above assumes you're building the form yourself; if you're not, you can combine this logic with a hook_form_alter() function. This example assumes you're adding it to a node add/edit form for the Basic Page content type:

function MYMODULE_form_page_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  $form['textarea']['#states'] = array(
    'visible' =&gt; array(
      ':input[name="name_of_radios_element"]' =&gt; array('value' =&gt; 'yes')
    )
  );
}


If you're using the second method you'll need to do some digging into the $form array to find out exactly which element you need to target. If you don't already have it I recommend installing the Devel module and using it's excellent dpm() function for your debugging.

There's more information on the various different options for #states on the drupal_process_states() docs page.