1 list.module list_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state)

Implements hook_field_formatter_settings_form().

File

core/modules/field/modules/list/list.module, line 594
Defines list field types that can be used with the Options module.

Code

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

  switch ($display['type']) {
    case 'boolean_yes_no':
      $element['format'] = array(
        '#type' => 'select',
        '#title' => t('Output format'),
        '#options' => list_boolean_display_format_options(),
        '#default_value' => $settings['format'],
      );

      $element['custom_on'] = array(
        '#type' => 'textfield',
        '#title' => t('Custom output for On'),
        '#default_value' => $settings['custom_on'],
        '#states' => array(
          'visible' => array(
            array(
              'select[name="fields[' . $field['field_name'] . '][settings_edit_form][settings][format]"]' => array('value' => 'custom'),
            ),
            array(
              'select[name="options[settings][format]"]' => array('value' => 'custom'),
            ),
          ),
        ),
      );

      $element['custom_off'] = array(
        '#type' => 'textfield',
        '#title' => t('Custom output for Off'),
        '#default_value' => $settings['custom_off'],
        '#states' => array(
          'visible' => array(
            array(
              'select[name="fields[' . $field['field_name'] . '][settings_edit_form][settings][format]"]' => array('value' => 'custom'),
            ),
            array(
              'select[name="options[settings][format]"]' => array('value' => 'custom'),
            ),
          ),
        ),
      );

      $element['reverse'] = array(
        '#type' => 'checkbox',
        '#title' => t('Reverse'),
        '#description' => t('If checked, true will be displayed as false.'),
        '#default_value' => $settings['reverse'],
      );
      break;
  }

  return $element;
}