Hide a CCK fieldgroup using #states in hook_form_alter()? I have a custom module, and I am trying to hide a CCK fieldgroup using "#states" when a certain item is selected in a drop-down select list.

I have tried using states from within hook_form_alter(), like so:

$form['group_mygroup']['#states']['invisible'] = array(
  ':input[name="field_trigger[' . LANGUAGE_NONE. ']"]' =&gt; array( 'value' =&gt; 'hide' ),
);


This doesn't seem to do anything.

I have looked at changing the weight of my module as per various sites like http://proofgroup.com/blog/2008/dec/modifying_cck_fieldgroups_hook_form_alter.

but still to no avail. I can hide all the form elements within the fieldgroup using states but not the field group itself. Does anyone have any idea?
/**
 * Implements hook_field_group_build_pre_render_alter.
 */
function mymodule_field_group_build_pre_render_alter(&$element) {
  if (isset($element['#form_id'])) {
    if ($element['#form_id'] == 'mynodetype_node_form') {
      $element['group_myfieldgroup']['#states'] = array(
        'visible' => array(
          ':input[name="field_myfield[und]"]' => array('checked' => TRUE),
        )
      );
      $element['group_myfieldgroup']['#id'] = 'group_myfieldgroup';
    }
  }
}


I use this hook to hide my field group. It's visible only if the checkbox field_myfield is checked. 

To explore $element variable in this hook I used 

die('&lt;pre&gt;'.print_r($element, 1).'&lt;/pre&gt;');


instead of dpm(). 

Hope it helped :)