Conditional field on checkbox is not woking If the checkbox is checked then it will show the textbox else not, for this purpose i've written this code. But it is not working, even the textfield is not showing.what do i need to change in this code ?  

      $form['details'] = array(
       '#type' =&gt; 'fieldset',
       '#title' =&gt; $this-&gt;t('Details'),
      );

      $form['details']['field_type'] = array(
       '#type'    =&gt; 'checkbox',
       '#default_value' =&gt; 0,
       '#title'   =&gt; t('Choose entry type.')
      );

     $form['details']['text'] = array(
      '#type'          =&gt; 'textfield',
      '#title'         =&gt; t('Enter the text'),
      '#states'        =&gt; array(
         'visible'      =&gt; array(
           ':input[name="field_type"]' =&gt; array('checked' =&gt; TRUE),
         ),
       ),
    );
Please try this code ... It works !!

$form['field_type'] = array(
  '#type'    =&gt; 'checkbox',
  '#default_value' =&gt; 0,
  '#title'   =&gt; t('Choose entry type.')
);

$form['text'] = array(
  '#type'          =&gt; 'textfield',
  '#title'         =&gt; t('Enter the text'),
  '#states'        =&gt; array(
     'visible'      =&gt; array(
       ':input[name="field_type"]' =&gt; array('checked' =&gt; TRUE),
     ),
   ),
);