function ds_fieldgroup_form in Display Suite 6.3
Same name and namespace in other branches
- 6 includes/ds.groups.inc \ds_fieldgroup_form()
- 6.2 includes/ds.groups.inc \ds_fieldgroup_form()
Fieldgroup form.
1 string reference to 'ds_fieldgroup_form'
- ds_fieldgroups in includes/
ds.groups.inc - Fieldgroups overview.
File
- includes/
ds.groups.inc, line 78 - Manage fieldgroups.
Code
function ds_fieldgroup_form($form_state, $module, $key = '', $fieldgroup = array()) {
$form = array();
if (empty($fieldgroup)) {
$fieldgroup = array(
'title' => '',
'exclude' => array(),
);
}
$form['identity'] = array(
'#type' => 'fieldset',
'#title' => empty($key) ? t('Add new fieldgroup') : t('Update fieldgroup'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
);
$form['identity']['key'] = array(
'#type' => 'textfield',
'#title' => 'Key name',
'#description' => t('The machine-readable name of this fieldgroup. Saving will automatically prepend <em>ds_group</em> to the key. <br /><strong>Warning: there is no validation against fields from other modules, so make sure you create a unique key.</strong>'),
'#required' => TRUE,
);
if (!empty($key)) {
$form['identity']['key']['#disabled'] = TRUE;
$form['identity']['key']['#value'] = $key;
$form['identity']['key']['#description'] = t('The machine-readable name of this fieldgroup. Note: you can not edit this key.');
}
$form['identity']['name'] = array(
'#type' => 'textfield',
'#title' => 'Fieldgroup name',
'#description' => t('The name of this fieldgroup which will be used for every type on the display fields page.'),
'#required' => TRUE,
'#default_value' => $fieldgroup['title'],
);
$api_info = ds_api_info($module);
if (isset($api_info['types']) && count($api_info['types']()) > 1) {
$types = array();
foreach ($api_info['types']() as $tkey => $type) {
$types[$tkey] = check_plain($type->name);
}
$form['identity']['exclude'] = array(
'#type' => 'checkboxes',
'#title' => t('Field exclude'),
'#options' => $types,
'#default_value' => $fieldgroup['exclude'],
'#attributes' => array(
'class' => 'exclude-types',
),
);
$form['identity']['exclude_all'] = array(
'#type' => 'checkbox',
'#title' => t('Select all'),
'#description' => t('Toggle types which you don\'t want the fieldgroups to appear in.'),
'#attributes' => array(
'class' => 'select-all',
),
);
}
else {
$form['identity']['exclude'] = array(
'#type' => 'value',
'#value' => array(),
);
}
$form['identity']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save fieldgroup'),
'#submit' => array(
'ds_fieldgroup_form_submit',
),
);
$form['#module'] = $module;
$form['#form_type'] = empty($key) ? 'insert' : 'update';
return $form;
}