You are here

public function TextFormatter::settingsForm in Heading field 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 FormatterBase::settingsForm

File

src/Plugin/Field/FieldFormatter/TextFormatter.php, line 33

Class

TextFormatter
Plugin to format string & text fields as a heading.

Namespace

Drupal\heading\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element['size'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Size'),
    '#default_value' => $this
      ->getSetting('size'),
    '#options' => [
      'h1' => $this
        ->t('Heading 1'),
      'h2' => $this
        ->t('Heading 2'),
      'h3' => $this
        ->t('Heading 3'),
      'h4' => $this
        ->t('Heading 4'),
      'h5' => $this
        ->t('Heading 5'),
      'h6' => $this
        ->t('Heading 6'),
    ],
  ];
  return $element;
}