function DecimalFormatter::settingsForm

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\DecimalFormatter::settingsForm()
  2. 10 core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\DecimalFormatter::settingsForm()
  3. 11.x core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\DecimalFormatter::settingsForm()

Overrides NumericFormatterBase::settingsForm

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php, line 40

Class

DecimalFormatter
Plugin implementation of the 'number_decimal' formatter.

Namespace

Drupal\Core\Field\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
    $elements = parent::settingsForm($form, $form_state);
    $elements['decimal_separator'] = [
        '#type' => 'select',
        '#title' => t('Decimal marker'),
        '#options' => [
            '.' => t('Decimal point'),
            ',' => t('Comma'),
        ],
        '#default_value' => $this->getSetting('decimal_separator'),
        '#weight' => 5,
    ];
    $elements['scale'] = [
        '#type' => 'number',
        '#title' => t('Scale', [], [
            'context' => 'decimal places',
        ]),
        '#min' => 0,
        '#max' => 10,
        '#default_value' => $this->getSetting('scale'),
        '#description' => t('The number of digits to the right of the decimal.'),
        '#weight' => 6,
    ];
    return $elements;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.