You are here

public function FilterHtml::settingsForm in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/filter/src/Plugin/Filter/FilterHtml.php \Drupal\filter\Plugin\Filter\FilterHtml::settingsForm()

Generates a filter's settings form.

Parameters

array $form: A minimally prepopulated form array.

\Drupal\Core\Form\FormStateInterface $form_state: The state of the (entire) configuration form.

Return value

array The $form array with additional form elements for the settings of this filter. The submitted form values should match $this->settings.

Overrides FilterBase::settingsForm

File

core/modules/filter/src/Plugin/Filter/FilterHtml.php, line 42

Class

FilterHtml
Provides a filter to limit allowed HTML tags.

Namespace

Drupal\filter\Plugin\Filter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $form['allowed_html'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Allowed HTML tags'),
    '#default_value' => $this->settings['allowed_html'],
    '#description' => $this
      ->t('A list of HTML tags that can be used. By default only the <em>lang</em> and <em>dir</em> attributes are allowed for all HTML tags. Each HTML tag may have attributes which are treated as allowed attribute names for that HTML tag. Each attribute may allow all values, or only allow specific values. Attribute names or values may be written as a prefix and wildcard like <em>jump-*</em>. JavaScript event attributes, JavaScript URLs, and CSS are always stripped.'),
    '#attached' => [
      'library' => [
        'filter/drupal.filter.filter_html.admin',
      ],
    ],
  ];
  $form['filter_html_help'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Display basic HTML help in long filter tips'),
    '#default_value' => $this->settings['filter_html_help'],
  ];
  $form['filter_html_nofollow'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Add rel="nofollow" to all links'),
    '#default_value' => $this->settings['filter_html_nofollow'],
  ];
  return $form;
}