2

I have created a field groups programmatically using this code:

in *.module file

/**
 * Implements hook_ctools_plugin_api()
 */
 function field_test_module3_ctools_plugin_api($module, $api) {

      if ($module == 'field_group' && $api == 'field_group') {
        return array('version' => 1);
  }
}

in *.field_group.inc

/** * Implements hook_field_group_info() */

function field_test_module3_field_group_info(){

 $field_groups = array();
 $field_group = new stdClass();
 $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially */
 $field_group->api_version = 1;
 $field_group->identifier = 'generale|node|field_esempio3|form';
 $field_group->group_name = 'generale';
 $field_group->entity_type = 'node';
 $field_group->bundle = 'field_esempio3';
 $field_group->mode = 'form';
 $field_group->parent_name = '';
 $field_group->data = array(
   'label' => 'Generale',
   'weight' => '2',
   'children' => array(
     0 => 'coverage',
   ),
   'format_type' => 'fieldset',
   'format_settings' => array(
     'formatter' => 'collapsed', //collapsible
     'instance_settings' => array(
       'description' => 'provo a creare un field group',
       'classes' => '', //generale field-group-fieldset
       'required_fields' => 1,
     ),
   ),
 );
 $field_groups['generale|node|field_esempio3|form'] = $field_group;

 return $field_groups; 
}

===================================================

Field groups is created but not dysplayed. Bottom of the page there is a section "Disabled fieldgroups" where it appears

enter image description here

If it's enable there are no problem but I need that fieldgroups is activated automatically. There is a way to enable this fieldgroups programatically?

Thank you.

-1

You can use the following code.

foreach($field_groups as $field_group){
    ctools_export_crud_enable('field_group',$field_group->identifier);
}
1
  • 1
    Can you give more details about where to put this code? I imagine that having it in hook_field_group_info() is not appropriate?
    – berliner
    Feb 21 '14 at 0:26

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.