You are here

public function NumericFormatterBase::settingsForm in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\NumericFormatterBase::settingsForm()
  2. 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\NumericFormatterBase::settingsForm()

Returns a form to configure settings for the formatter.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase 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.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form elements for the formatter settings.

Overrides FormatterBase::settingsForm

1 call to NumericFormatterBase::settingsForm()
DecimalFormatter::settingsForm in core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php
Returns a form to configure settings for the formatter.
1 method overrides NumericFormatterBase::settingsForm()
DecimalFormatter::settingsForm in core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php
Returns a form to configure settings for the formatter.

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php, line 17

Class

NumericFormatterBase
Parent plugin for decimal and integer formatters.

Namespace

Drupal\Core\Field\Plugin\Field\FieldFormatter

Code

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