function FieldgroupCRUDTest::createGroup in Content Construction Kit (CCK) 6.3
Creates a fieldgroup with a predictable name. Also makes all future calls to functions which take an optional fieldgroup use this one as the default.
Parameters
$settings Array to be passed to fieldgroup_save_group.:
$content_type Either a content type object, or the index of an acquired content type:
Return value
The newly created fieldgroup.
1 call to FieldgroupCRUDTest::createGroup()
File
- tests/
fieldgroup.test, line 25
Class
Code
function createGroup($settings, $fields = array(), $content_type = 0) {
if (is_numeric($content_type) && isset($this->content_types[$content_type])) {
$content_type = $this->content_types[$content_type];
}
$type_name = $content_type->type;
$group_name = 'simpletest_g' . $this->next_group_n++;
$defaults = array(
'group_name' => $group_name,
'group_type' => 'standard',
'parent' => '',
'label' => $group_name,
'weight' => -3,
'settings' => array(
'form' => array(
'style' => 'fieldset',
'description' => '',
),
'display' => array(
'weight' => -3,
'parent' => '',
'label' => 'above',
'description' => '',
'teaser' => array(
'format' => 'fieldset',
'exclude' => 0,
),
'full' => array(
'format' => 'fieldset',
'exclude' => 0,
),
),
),
);
$group = $settings + $defaults;
fieldgroup_save_group($type_name, $group);
$this->last_group = $group_name;
foreach ($fields as $field_name) {
$form_values = array(
'field_name' => $field_name,
'group' => $group_name,
'type_name' => $type_name,
);
fieldgroup_update_fields($form_values);
}
cache_clear_all('fieldgroup_data:', content_cache_tablename(), TRUE);
return $this->last_group;
}