function quicktabs_field_collection_field_formatter_settings_form in QuickTabs Field Collection 7
Implements hook_field_formatter_settings_form().
File
- ./
quicktabs_field_collection.module, line 70 - Renders a field collection as QuickTabs.
Code
function quicktabs_field_collection_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$options = array();
$field_collections = field_info_instances('field_collection_item', $field['field_name']);
foreach ($field_collections as $field_name => $field) {
$options[$field_name] = $field['label'] . ' (' . $field_name . ')';
}
$view_modes = array(
'field' => t('Field only'),
);
$entity_info = entity_get_info('field_collection_item');
foreach ($entity_info['view modes'] as $key => $info) {
$view_modes[$key] = $info['label'] . ' (' . $key . ')';
}
$element['tab_field'] = array(
'#type' => 'select',
'#title' => t('Label field'),
'#description' => t('The field collection field to use for the tab label.'),
'#required' => TRUE,
'#options' => $options,
'#default_value' => $settings['tab_field'],
);
$element['content_options'] = array(
'#type' => 'fieldset',
'#title' => t('Body'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#tree' => TRUE,
);
$element['content_options']['content_view_mode'] = array(
'#type' => 'select',
'#title' => t('View mode'),
'#description' => t('The field collection view mode to use for rendering. If the field option is selected then a field to display must be chosen.'),
'#required' => TRUE,
'#options' => $view_modes,
'#default_value' => $settings['content_options']['content_view_mode'],
'#attributes' => array(
'class' => array(
'qtfc-view-mode-select',
),
),
);
$element['content_options']['content_field'] = array(
'#type' => 'select',
'#title' => t('Field'),
'#description' => t('The field collection field to use for the tab body.'),
'#required' => FALSE,
'#options' => $options,
'#default_value' => $settings['content_options']['content_field'],
'#states' => array(
'enabled' => array(
'select.qtfc-view-mode-select' => array(
'value' => 'field',
),
),
),
'#element_validate' => array(
'quicktabs_field_collection_validate_content_field',
),
);
$element['content_options']['content_field_striptags'] = array(
'#type' => 'checkbox',
'#title' => t('Strip tags'),
'#description' => t("Strip all HTML tags from the value used for the tab's content."),
'#default_value' => $settings['content_options']['content_field_striptags'],
);
quicktabs_field_collection_get_quicktabs_options($element, $settings);
$element['classes'] = array(
'#type' => 'textfield',
'#title' => t('Custom Classes'),
'#description' => t('Provide a space delimited list of css classes to use.'),
'#default_value' => $settings['classes'],
);
return $element;
}