I am trying to automatically group fields created by my custom module, but it's not quite working. My expectation is that a field group will be created and existing fields would be assigned to it. I'm using the Field Groups module, as it appears to be pretty standard.
As advised on http://drupal.org/node/1606758, I have used ctools bulk export to generate the code. I have moved the following code into my module. Not sure why this isn't working:
- My
hook_field_group_info()andhook_ctools_plugin_api()are both being hit; the debugging flags I've added are being logged. - The specified fields are named correctly and do exist in the database.
What I might be doing wrong?
========== From Ctools Bulk Exporter: ===========
Place this in nmc_directory.info
name = nmc_directory export module
description = Export objects from CTools
dependencies[] = field_group
package = Chaos tool suite
core = 7.x
Place this in nmc_directory.module
<?php
/**
* Implements hook_ctools_plugin_api().
*/
function nmc_directory_ctools_plugin_api($module, $api) {
if ($module == 'field_group' && $api == 'field_group') {
return array('version' => 1);
}
}
Place this in nmc_directory.field_group.inc
<?php
/**
* Implements hook_field_group_info().
*/
function nmc_directory_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 = 'group_dir_phys_consumer_info|node|dir_physicians|form';
$field_group->group_name = 'group_dir_phys_consumer_info';
$field_group->entity_type = 'node';
$field_group->bundle = 'dir_physicians';
$field_group->mode = 'form';
$field_group->parent_name = '';
$field_group->data = array(
'label' => 'Online Medical Providers Directory: Website (Consumer Information)',
'weight' => '0',
'children' => array(
0 => 'dir_phys_gender',
1 => 'dir_phys_category',
2 => 'dir_phys_title',
3 => 'dir_phys_fname',
4 => 'dir_phys_lname',
5 => 'dir_phys_suffix',
6 => 'dir_phys_medfield_1',
7 => 'dir_phys_medfield_2',
8 => 'dir_phys_phone_public',
),
'format_type' => 'fieldset',
'format_settings' => array(
'label' => 'Online Medical Providers Directory: Website (Consumer Information)',
'instance_settings' => array(
'required_fields' => 1,
'classes' => '',
'description' => '',
),
'formatter' => 'collapsed',
),
);
$field_groups['group_dir_phys_consumer_info|node|dir_physicians|form'] = $field_group;
return $field_groups;
}