0

I'm using Field group Module, I have created 3 groups with name & ID as given below:

Group Name    | Machine ID
Stake Holders | group_sh1  
Trends        | group_td1  
Organization  | group_org1 

I want to retrieve the group name in a custom module. By using "ctools" I'm able to retrieve the id of the group, but couldn't get name of the group. Please find the code below for your reference.

ctools_include('export');
$objects = ctools_export_load_object('field_group', 'conditions', array(
    'entity_type' => 'node',
    'bundle' => DIGITAL_IQ,
  ));

$object = array_shift($objects);
if ($object && isset($object->data)) {
  dpm(field_group_unpack($object)children);
}

--Result---
0 (String, 9 characters ) group_sh1
1 (String, 9 characters ) group_td1
2 (String, 10 characters ) group_org1

How can I retrieve the group name?

1
//Get the Field information.
$field = field_info_instance('node', 'field_business_challenge', DIGITAL_IQ);


//Obtain group of that field.
$field_group = field_get_field_group($field); 


//Get the name of the group from the Lable Attribute.
dpm($field->Lable);

There you go, you have the group name.

  • Are you sure it's $field->Lable? – kiamlaluno Dec 7 '12 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.