How to count the children (elements) inside a fieldgroup? I use the Field Group module in a website and I'm trying to count the fields within a Field Group.

I tried …

$num_of_fields = count($content['group_name']['children']);

echo $num_of_fields;


… but it doesn't seem to work. What am I doing wrong?
If you use the following code you will see the value that you need.

/**
 * Implements hook_form_alter().
 */
function YOUR_MODULE_form_alter(&amp;$form, &amp;$form_state, $form_id) {      
   //you need the devel module to use dpm() function
  //My field group name is group_g2
  dpm(count($form['#groups']['group_g2']-&gt;children));
}


Is easy to track values if you use the Devel and Search Krumo modules