I create my fields and fieldgroups programmatically by using field_create_field(), field_create_instance() and hook_field_group_info(). When I now go to "Manage Fields" or "Manage Display" the fields appear in their groups. When I try to change the group for one of the fields, my changes won't get saved. However I can rearrange the order of the fields within the same fieldgroup.

Comments

willmoy’s picture

Connected issue but, I think, a feature request: I'd like to be able to move fields into core field groups/vertical tabs, so create a field and add it to 'publishing options' on the node form, for example.

Stalski’s picture

Status: Active » Fixed

The first issue, I tried with a custom module, code beneath and it worked. This should be fixed in dev.
I pushed a little more documentation in field_group.api.php file

@willmoy: you can now create a vertical tab (without a group) and it should be within the bottom "core" vertical tabs section. However, you will not be able to move them to the existing ones them self (like inside publishing options)

/**
 * Implement hook_ctools_plugin_api().
 * This hook is needed to let ctools know about exportables.
 * If you create field groups by using hook_field_group_info, you
 * will need to include the ctools api hook as well.
 */
function custom_ctools_plugin_api($module, $api) {
  if ($module == 'field_group' && $api == 'field_group') {
    return array('version' => 1);
  }
}

/**
 * Implementation of hook_field_group_info()
 */
function custom_field_group_info() {
  $field_groups = array();

  $field_group = new stdClass;
  $field_group->api_version = 1;
  $field_group->identifier = 'group_incode|node|page_simple|form';
  $field_group->group_name = 'group_incode';
  $field_group->entity_type = 'node';
  $field_group->bundle = 'page_simple';
  $field_group->mode = 'form';
  $field_group->parent_name = '';
  $field_group->data = array(
    'label' => 'content ',
    'weight' => '1',
    'children' => array(
      0 => 'body',
    ),
    'format_type' => 'fieldset',
    'format_settings' => array(
      'formatter' => 'collapsible',
      'instance_settings' => array(
        'classes' => '',
        'required_fields' => 1,
      ),
    ),
  );
  $field_groups['group_incode|node|page_simple|form'] = $field_group;

  return $field_groups;
}
chevron’s picture

Hi Stalski,
it works fine for mode 'form', however if I apply my fieldgroups to a view mode i cannot move the fields.

Stalski’s picture

Status: Fixed » Active
Stalski’s picture

It's equivalent in the default view mode works too for me.
Are you sure the view mode is correct ("_", "-" replacements or other signs perhaps) ?


  $field_group = new stdClass;
  $field_group->api_version = 1;
  $field_group->identifier = 'group_incode|node|page_simple|default';
  $field_group->group_name = 'group_incode';
  $field_group->entity_type = 'node';
  $field_group->bundle = 'page_simple';
  $field_group->mode = 'default';
  $field_group->parent_name = '';
  $field_group->data = array(
    'label' => 'content ',
    'weight' => '1',
    'children' => array(
      0 => 'body',
    ),
    'format_type' => 'fieldset',
    'format_settings' => array(
      'formatter' => 'collapsible',
      'instance_settings' => array(
        'classes' => '',
        'required_fields' => 1,
      ),
    ),
  );
  $field_groups['group_incode|node|page_simple|default'] = $field_group;
Stalski’s picture

Status: Active » Fixed

I can not reproduce it somehow. You can upgrade to stable version and run updates.
I hope it's fixed for you too. If you can add steps for me to have the problem you have, please do.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.