You are here

function title_field_formatter_settings_form in Title 7

Implements hook_field_formatter_settings_form().

File

./title.field.inc, line 30
Implement a title field formater.

Code

function title_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $settings = $instance['display'][$view_mode]['settings'];
  $element = array();
  $wrap_tags = array(
    '_none' => t('- None -'),
    'div' => t('DIV'),
    'h1' => t('H1'),
    'h2' => t('H2'),
    'h3' => t('H3'),
    'h4' => t('H4'),
    'h5' => t('H5'),
    'h6' => t('H6'),
    'span' => t('SPAN'),
  );
  $element['title_style'] = array(
    '#title' => t('Wrap title in tag'),
    '#type' => 'select',
    '#default_value' => !empty($settings['title_style']) ? $settings['title_style'] : '_none',
    '#options' => $wrap_tags,
  );
  $link_types = array(
    'content' => t('Content (relative url)'),
    'content_absolute' => t('Content (absolute url)'),
  );
  $element['title_link'] = array(
    '#title' => t('Link title to'),
    '#type' => 'select',
    '#default_value' => $settings['title_link'],
    '#empty_option' => t('Nothing'),
    '#options' => $link_types,
  );
  $element['enable_trim'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable trimming?'),
    '#default_value' => $settings['enable_trim'],
  );
  $element['trim_length'] = array(
    '#title' => t('Trim length'),
    '#type' => 'textfield',
    '#size' => 10,
    '#default_value' => $settings['trim_length'],
    '#element_validate' => array(
      'element_validate_integer_positive',
    ),
    '#states' => array(
      'visible' => array(
        ':input[name*="enable_trim"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $element['title_class'] = array(
    '#title' => t('Tag classes'),
    '#type' => 'textfield',
    '#description' => t('A CSS class to use in the wrapper tag for the title.'),
    '#default_value' => $settings['title_class'],
    '#element_validate' => array(
      '_title_validate_class',
    ),
  );
  return $element;
}