public function RangeDecimalFormatter::settingsForm in Range 8
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 RangeIntegerFormatter::settingsForm
File
- src/
Plugin/ Field/ FieldFormatter/ RangeDecimalFormatter.php, line 38
Class
- RangeDecimalFormatter
- Plugin implementation of the 'range_decimal' formatter.
Namespace
Drupal\range\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$elements = parent::settingsForm($form, $form_state);
$elements['decimal_separator'] = [
'#type' => 'select',
'#title' => $this
->t('Decimal marker'),
'#options' => [
'.' => $this
->t('Decimal point'),
',' => $this
->t('Comma'),
],
'#default_value' => $this
->getSetting('decimal_separator'),
'#weight' => 10,
];
$range = range(0, 10);
$elements['scale'] = [
'#type' => 'select',
'#title' => $this
->t('Scale', [], [
'decimal places',
]),
'#options' => array_combine($range, $range),
'#default_value' => $this
->getSetting('scale'),
'#description' => $this
->t('The number of digits to the right of the decimal.'),
'#weight' => 15,
];
return $elements;
}