public function DefaultNumberFormatter::settingsForm

Returns a form to configure settings for the formatter.

Invoked from \Drupal\field_ui\Form\FieldInstanceEditForm to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.

Parameters

array $form: The form where the settings form is being included in.

array $form_state: An associative array containing the current state of the form.

Return value

array The form elements for the formatter settings.

Overrides FormatterBase::settingsForm

1 call to DefaultNumberFormatter::settingsForm()
1 method overrides DefaultNumberFormatter::settingsForm()

File

drupal/core/modules/number/lib/Drupal/number/Plugin/field/formatter/DefaultNumberFormatter.php, line 23
Contains \Drupal\number\Plugin\field\formatter\DefaultNumberFormatter.

Class

DefaultNumberFormatter
Parent plugin for decimal and integer formatters

Namespace

Drupal\number\Plugin\field\formatter

Code

public function settingsForm(array $form, array &$form_state) {
  $options = array(
    '' => t('- None -'),
    '.' => t('Decimal point'),
    ',' => t('Comma'),
    ' ' => t('Space'),
    chr(8201) => t('Thin space'),
    "'" => t('Apostrophe'),
  );
  $elements['thousand_separator'] = array(
    '#type' => 'select',
    '#title' => t('Thousand marker'),
    '#options' => $options,
    '#default_value' => $this
      ->getSetting('thousand_separator'),
    '#weight' => 0,
  );
  $elements['prefix_suffix'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display prefix and suffix.'),
    '#default_value' => $this
      ->getSetting('prefix_suffix'),
    '#weight' => 10,
  );
  return $elements;
}