Drupal - Hide a CCK fieldgroup using #states in hook_form_alter()?
/** * 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('<pre>'.print_r($element, 1).'</pre>');
instead of dpm()
.
Hope it helped :)