1 number.module number_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state)

Implements hook_field_formatter_settings_form().

File

core/modules/field/modules/number/number.module, line 227
Defines numeric field types.

Code

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

  if ($display['type'] == 'number_decimal' || $display['type'] == 'number_integer') {
    $options = array(
      '' => t('<none>'),
      '.' => t('Decimal point'),
      ',' => t('Comma'),
      ' ' => t('Space'),
    );
    $element['thousand_separator'] = array(
      '#type' => 'select',
      '#title' => t('Thousand marker'),
      '#options' => $options,
      '#default_value' => $settings['thousand_separator'],
    );

    if ($display['type'] == 'number_decimal') {
      $element['decimal_separator'] = array(
        '#type' => 'select',
        '#title' => t('Decimal marker'),
        '#options' => array('.' => t('Decimal point'), ',' => t('Comma')),
        '#default_value' => $settings['decimal_separator'],
      );
      $element['scale'] = array(
        '#type' => 'select',
        '#title' => t('Scale'),
        '#options' => backdrop_map_assoc(range(0, 10)),
        '#default_value' => $settings['scale'],
        '#description' => t('The number of digits to the right of the decimal.'),
      );
    }

    $element['prefix_suffix'] = array(
      '#type' => 'checkbox',
      '#title' => t('Display prefix and suffix.'),
      '#default_value' => $settings['prefix_suffix'],
    );
  }

  return $element;
}