You are here

function faqfield_field_formatter_settings_form in FAQ Field 7

Implements hook_field_formatter_settings_form().

File

./faqfield.module, line 271
FAQ Field Provides a field for frequently asked questions.

Code

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

    // Accordion display settings.
    case 'faqfield_accordion':

      // Number of first active element.
      $element['active'] = array(
        '#type' => 'textfield',
        '#title' => t('Active'),
        '#default_value' => $settings['active'],
        '#description' => t('Index of active element starting from 0. Leave empty to display none at start.'),
        // @TODO _element_validate_number() is deprecated since 7.8.
        '#element_validate' => array(
          function_exists('element_validate_number') ? 'element_validate_number' : '_element_validate_number',
        ),
        '#maxlength' => 3,
        '#size' => 5,
      );

      // Whether auto heigth is enabled.
      $element['autoHeight'] = array(
        '#type' => 'checkbox',
        '#title' => t('Auto height'),
        '#default_value' => $settings['autoHeight'],
        '#description' => t('If set, the highest content part is used as height reference for all other parts. Provides more consistent animations.'),
      );

      // Whether elements are collabsible.
      $element['collapsible'] = array(
        '#type' => 'checkbox',
        '#title' => t('Collapsible'),
        '#default_value' => $settings['collapsible'],
        '#description' => t('Whether an opened question can be collapsed (by the triggering event).'),
      );

      // Name of triggering event.
      $element['event'] = array(
        '#type' => 'textfield',
        '#title' => t('Event'),
        '#default_value' => $settings['event'],
        '#description' => t('The event on which to trigger the accordion.'),
        '#maxlength' => 10,
      );
      break;

    // Anchor list formatter settings.
    case 'faqfield_anchor_list':

      // Input for the count of rows for the answer field.
      $element['anchor-list-type'] = array(
        '#type' => 'select',
        '#title' => t('Anchor link list type'),
        '#default_value' => $settings['anchor-list-type'],
        '#options' => array(
          'ul' => t('<ul> - Bullet list'),
          'ol' => t('<ol> - Numeric list'),
        ),
        '#description' => t('The type of HTML list used for the anchor link list.'),
      );
      break;
  }
  return $element;
}