function TextItemBase::fieldSettingsForm

Same name and namespace in other branches
  1. 10 core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php \Drupal\text\Plugin\Field\FieldType\TextItemBase::fieldSettingsForm()

Overrides FieldItemBase::fieldSettingsForm

1 call to TextItemBase::fieldSettingsForm()
TextWithSummaryItem::fieldSettingsForm in core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php
Returns a form for the field-level settings.
1 method overrides TextItemBase::fieldSettingsForm()
TextWithSummaryItem::fieldSettingsForm in core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php
Returns a form for the field-level settings.

File

core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php, line 27

Class

TextItemBase
Base class for 'text' configurable field types.

Namespace

Drupal\text\Plugin\Field\FieldType

Code

public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
  $element = parent::fieldSettingsForm($form, $form_state);
  $settings = $this->getSettings();
  $element['allowed_formats'] = [
    '#type' => 'checkboxes',
    '#title' => $this->t('Allowed text formats'),
    '#options' => $this->get('format')
      ->getPossibleOptions(),
    '#default_value' => !empty($settings['allowed_formats']) ? $settings['allowed_formats'] : [],
    '#description' => $this->t('Select the allowed text formats. If no formats are selected, all available text formats will be displayed to the user.'),
    '#element_validate' => [
      [
        static::class,
        'validateAllowedFormats',
      ],
    ],
  ];
  return $element;
}

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