You are here

function cshs_field_formatter_settings_form in Client-side Hierarchical Select 7

Implements hook_field_formatter_settings_form().

File

./cshs.formatter.inc, line 44
All implementations of field formatters.

Code

function cshs_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $element = array();

  // Add settings for all CSHS formatters.
  $element['linked'] = array(
    '#title' => t('Link to term page'),
    '#type' => 'checkbox',
    '#default_value' => $settings['linked'],
  );

  // Add special formatter settings.
  switch ($display['type']) {
    case 'cshs_term_reference_hierarchical_text':
    case 'cshs_term_reference_group_by_root':
      $element['separator'] = array(
        '#title' => t('Separator'),
        '#description' => t('Specify a separator which will be placed in between the different hierarchy levels.'),
        '#type' => 'textfield',
        '#default_value' => $settings['separator'],
      );
      break;
    case 'cshs_term_reference_flexible_hierarchy':
      $element['format'] = array(
        '#title' => t('Format'),
        '#description' => t('Specify a format for each field item by using tokens.'),
        '#type' => 'textfield',
        '#default_value' => $settings['format'],
      );
      break;
  }
  return $element;
}