function field_collection_table_field_formatter_settings_form in Field Collection Table 7
Implements hook_field_formatter_settings_form().
File
- ./
field_collection_table.module, line 318 - Module implementing a field-collection table formatter.
Code
function field_collection_table_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$element = field_collection_field_formatter_settings_form($field, $instance, $view_mode, $form, $form_state);
$field_collections = field_info_instances('field_collection_item', $instance['field_name']);
$field_options = array(
'none' => t('None'),
);
foreach ($field_collections as $key => $value) {
$field_options[$key] = $value['label'];
}
if (!empty($element['view_mode'])) {
$element['view_mode']['#description'] = t('Used to determine which fields should be displayed.');
}
$element['hide_empty'] = array(
'#type' => 'checkbox',
'#title' => t('Hide empty collection'),
'#default_value' => $settings['hide_empty'],
'#description' => t('If enabled, nothing will be displayed for an empty collection (not even the add link).'),
);
$element['empty'] = array(
'#type' => 'checkbox',
'#title' => t('Hide empty columns'),
'#description' => t('If checked, hides empty table columns.'),
'#default_value' => $settings['empty'],
);
$element['caption'] = array(
'#type' => 'textfield',
'#title' => t('Table caption'),
'#description' => t('Displayed in the caption element above the table'),
'#default_value' => $settings['caption'],
);
$element['orientation'] = array(
'#type' => 'select',
'#title' => t('Orientation'),
'#description' => t('Set the orientation of the table'),
'#options' => array(
'columns' => t('Columns'),
'rows' => t('Rows'),
),
'#default_value' => $settings['orientation'],
);
$element['header_column'] = array(
'#type' => 'select',
'#title' => t('Header field'),
'#description' => t('The selected field value will be used as the horizontal table header'),
'#options' => $field_options,
'#states' => array(
'visible' => array(
':input[name="fields[field_fc][settings_edit_form][settings][orientation]"]' => array(
'value' => 'rows',
),
),
),
);
return $element;
}