You are here

function range_field_formatter_settings_form in Range 7

Implements hook_field_formatter_settings_form().

File

./range.module, line 312
Defines range field types.

Code

function range_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $element = array();
  if ($display['type'] === 'range_decimal' || $display['type'] === 'range_integer') {
    $element['thousand_separator'] = array(
      '#type' => 'select',
      '#title' => t('Thousand marker'),
      '#options' => array(
        '' => t('<none>'),
        '.' => t('Decimal point'),
        ',' => t('Comma'),
        ' ' => t('Space'),
      ),
      '#default_value' => $settings['thousand_separator'],
    );
  }
  if ($display['type'] === 'range_decimal') {
    $element['decimal_separator'] = array(
      '#type' => 'select',
      '#title' => t('Decimal marker'),
      '#options' => array(
        '.' => t('Decimal point'),
        ',' => t('Comma'),
        ', ' => t('Comma and space'),
      ),
      '#default_value' => $settings['decimal_separator'],
    );
    $element['scale'] = array(
      '#type' => 'select',
      '#title' => t('Scale'),
      '#options' => drupal_map_assoc(range(0, 10)),
      '#default_value' => $settings['scale'],
      '#description' => t('The number of digits to the right of the decimal.'),
    );
  }
  if ($display['type'] === 'range_integer_sprintf' || $display['type'] === 'range_decimal_sprintf') {
    $element['format_string'] = array(
      '#type' => 'textfield',
      '#title' => t('Format'),
      '#description' => t('See <a href="!url">PHP documentation</a> for a description of format. <strong>Due to PHP limitations, thousand separator cannot be used.</strong>', array(
        '!url' => 'http://php.net/manual/en/function.sprintf.php',
      )),
      '#default_value' => $settings['format_string'],
    );
  }
  _range_field_formatter_base_settings_form($element, $settings, $field['field_name']);
  return $element;
}