You are here

function taxtocomma_field_formatter_settings_form in Taxonomy Formatter 7

Implements hook_field_formatter_settings_form().

File

./taxonomy_formatter.module, line 29
adds a formatter for taxonomy terms with options to specify element type, wrapper type, and separators

Code

function taxtocomma_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $element = array();
  $element['links_option'] = array(
    '#type' => 'checkbox',
    '#title' => t('Links'),
    '#description' => t('When checked terms will be displayed as links'),
    '#default_value' => $settings['links_option'],
  );
  $element['separator_option'] = array(
    '#type' => 'textfield',
    '#title' => t('Separator'),
    '#description' => t('The separator to use, including leading and trailing spaces'),
    '#default_value' => $settings['separator_option'],
  );
  $element['element_option'] = array(
    '#type' => 'select',
    '#title' => t('Element'),
    '#description' => t('The HTML element to wrap each tag in'),
    '#default_value' => $settings['element_option'],
    '#options' => array(
      '- None -' => '- None -',
      'span' => 'span',
      'h1' => 'h1',
      'h2' => 'h2',
      'h3' => 'h3',
      'h4' => 'h4',
      'h5' => 'h5',
      'strong' => 'h6',
      'em' => 'h7',
    ),
  );
  $element['element_class'] = array(
    '#type' => 'textfield',
    '#title' => t('Element Class'),
    '#description' => t('The class assigned to the element'),
    '#default_value' => $settings['element_class'],
  );
  $element['wrapper_option'] = array(
    '#type' => 'select',
    '#title' => t('Wrapper'),
    '#description' => t('The HTML element to wrap the entire collection in'),
    '#default_value' => $settings['wrapper_option'],
    '#options' => array(
      '- None -' => '- None -',
      'div' => 'div',
      'span' => 'span',
      'h1' => 'h1',
      'h2' => 'h2',
      'h3' => 'h3',
      'h4' => 'h4',
      'h5' => 'h5',
      'p' => 'p',
      'strong' => 'strong',
      'em' => 'em',
    ),
  );
  $element['wrapper_class'] = array(
    '#type' => 'textfield',
    '#title' => t('Wrapper Class'),
    '#description' => t('The class assigned to the wrapper'),
    '#default_value' => $settings['wrapper_class'],
  );
  return $element;
}