function hook_field_group_format_settings in Field Group 7.2
Same name and namespace in other branches
- 7 field_group.api.php \hook_field_group_format_settings()
Implements hook_field_group_format_settings().
Defines configuration widget for the settings on a field group formatter. Eache formatter can have different elements and storage.
@params Object $group The group object.
Return value
Array $form The form element for the format settings.
1 function implements hook_field_group_format_settings()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- field_group_field_group_format_settings in ./
field_group.module - Implements hook_field_group_format_settings(). If the group has no format settings, default ones will be added. @params Object $group The group object.
2 invocations of hook_field_group_format_settings()
- field_group_field_group_format_summary in ./
field_group.module - Implements hook_field_group_format_summary().
- field_group_format_settings_form in ./
field_group.field_ui.inc - Creates a form for field_group formatters.
File
- ./
field_group.api.php, line 117 - Hooks provided by the Field group module.
Code
function hook_field_group_format_settings($group) {
// Add a wrapper for extra settings to use by others.
$form = array(
'instance_settings' => array(
'#tree' => TRUE,
'#weight' => 2,
),
);
$field_group_types = field_group_formatter_info();
$mode = $group->mode == 'form' ? 'form' : 'display';
$formatter = $field_group_types[$mode][$group->format_type];
// Add the required formatter type selector.
if (isset($formatter['format_types'])) {
$form['formatter'] = array(
'#title' => t('Fieldgroup settings'),
'#type' => 'select',
'#options' => drupal_map_assoc($formatter['format_types']),
'#default_value' => isset($group->format_settings['formatter']) ? $group->format_settings['formatter'] : $formatter['default_formatter'],
'#weight' => 1,
);
}
if ($mode == 'form') {
$form['instance_settings']['required_fields'] = array(
'#type' => 'checkbox',
'#title' => t('Mark group for required fields.'),
'#default_value' => isset($group->format_settings['instance_settings']['required_fields']) ? $group->format_settings['instance_settings']['required_fields'] : (isset($formatter['instance_settings']['required_fields']) ? $formatter['instance_settings']['required_fields'] : ''),
'#weight' => 2,
);
}
$form['instance_settings']['classes'] = array(
'#title' => t('Extra CSS classes'),
'#type' => 'textfield',
'#default_value' => isset($group->format_settings['instance_settings']['classes']) ? $group->format_settings['instance_settings']['classes'] : (isset($formatter['instance_settings']['classes']) ? $formatter['instance_settings']['classes'] : ''),
'#weight' => 3,
'#element_validate' => array(
'field_group_validate_css_class',
),
);
$form['instance_settings']['description'] = array(
'#title' => t('Description'),
'#type' => 'textarea',
'#default_value' => isset($group->format_settings['instance_settings']['description']) ? $group->format_settings['instance_settings']['description'] : (isset($formatter['instance_settings']['description']) ? $formatter['instance_settings']['description'] : ''),
'#weight' => 0,
);
// Add optional instance_settings.
switch ($group->format_type) {
case 'div':
$form['instance_settings']['effect'] = array(
'#title' => t('Effect'),
'#type' => 'select',
'#options' => array(
'none' => t('None'),
'blind' => t('Blind'),
),
'#default_value' => isset($group->format_settings['instance_settings']['effect']) ? $group->format_settings['instance_settings']['effect'] : $formatter['instance_settings']['effect'],
'#weight' => 2,
);
$form['instance_settings']['speed'] = array(
'#title' => t('Speed'),
'#type' => 'select',
'#options' => array(
'none' => t('None'),
'slow' => t('Slow'),
'fast' => t('Fast'),
),
'#default_value' => isset($group->format_settings['instance_settings']['speed']) ? $group->format_settings['instance_settings']['speed'] : $formatter['instance_settings']['speed'],
'#weight' => 3,
);
break;
case 'fieldset':
$form['instance_settings']['classes'] = array(
'#title' => t('Extra CSS classes'),
'#type' => 'textfield',
'#default_value' => isset($group->format_settings['instance_settings']['classes']) ? $group->format_settings['instance_settings']['classes'] : $formatter['instance_settings']['classes'],
'#weight' => 3,
'#element_validate' => array(
'field_group_validate_css_class',
),
);
break;
case 'tabs':
case 'htabs':
case 'accordion':
unset($form['instance_settings']['description']);
if (isset($form['instance_settings']['required_fields'])) {
unset($form['instance_settings']['required_fields']);
}
break;
case 'tab':
case 'htab':
case 'accordion-item':
default:
}
return $form;
}