You are here

public function RangeIntegerSprintfFormatter::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 RangeFormatterBase::settingsForm

File

src/Plugin/Field/FieldFormatter/RangeIntegerSprintfFormatter.php, line 37

Class

RangeIntegerSprintfFormatter
Plugin implementation of the 'range_integer_sprintf' formatter.

Namespace

Drupal\range\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $elements = parent::settingsForm($form, $form_state);
  $elements['format_string'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Format'),
    '#description' => $this
      ->t('See <a href=":url" target="_blank">PHP documentation</a> for a description of the format. <strong>Due to PHP limitations, a thousand separator cannot be used.</strong>', [
      ':url' => 'http://php.net/manual/en/function.sprintf.php',
    ]),
    '#default_value' => $this
      ->getSetting('format_string'),
    '#weight' => 10,
  ];
  return $elements;
}