You are here

public function XBBCodeFilter::settingsForm in Extensible BBCode 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/Filter/XBBCodeFilter.php \Drupal\xbbcode\Plugin\Filter\XBBCodeFilter::settingsForm()
  2. 4.0.x src/Plugin/Filter/XBBCodeFilter.php \Drupal\xbbcode\Plugin\Filter\XBBCodeFilter::settingsForm()

Settings callback for the filter settings of xbbcode.

Overrides FilterBase::settingsForm

File

src/Plugin/Filter/XBBCodeFilter.php, line 55
Contains Drupal\xbbcode\Plugin\Filter\XBBCodeFilter.

Class

XBBCodeFilter
Provides a filter that converts BBCode to HTML.

Namespace

Drupal\xbbcode\Plugin\Filter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $form['linebreaks'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Convert linebreaks to HTML.'),
    '#default_value' => $this->settings['linebreaks'],
    '#description' => $this
      ->t('Newline <code>\\n</code> characters will become <code>&lt;br /&gt;</code> characters.'),
  ];
  $form['override'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Override the <a href="@url">global settings</a> with specific settings for this format.', [
      '@url' => Drupal::url('xbbcode.admin_handlers'),
    ]),
    '#default_value' => $this->settings['override'],
    '#description' => $this
      ->t('Overriding the global settings allows you to disallow or allow certain special tags for this format, while other formats will not be affected by the change.'),
    '#attributes' => [
      'onchange' => 'Drupal.toggleFieldset(jQuery("#edit-filters-xbbcode-settings-tags"))',
    ],
  ];
  $form = XBBCodeHandlerForm::buildFormHandlers($form, $this->tag_settings);
  $form['handlers']['#type'] = 'details';
  $form['handlers']['#open'] = $this->settings['override'];
  $parents = $form['#parents'];
  $parents[] = 'tags';
  $form['handlers']['tags']['#parents'] = $parents;
  $form['handlers']['extra']['tags']['#parents'] = $parents;
  return $form;
}