public function XBBCodeFilter::settingsForm in Extensible BBCode 8.3
Same name and namespace in other branches
- 8.2 src/Plugin/Filter/XBBCodeFilter.php \Drupal\xbbcode\Plugin\Filter\XBBCodeFilter::settingsForm()
- 4.0.x src/Plugin/Filter/XBBCodeFilter.php \Drupal\xbbcode\Plugin\Filter\XBBCodeFilter::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
- src/
Plugin/ Filter/ XBBCodeFilter.php, line 146
Class
- XBBCodeFilter
- Provides a filter that converts BBCode to HTML.
Namespace
Drupal\xbbcode\Plugin\FilterCode
public function settingsForm(array $form, FormStateInterface $form_state) : array {
$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><br /></code> tags.'),
];
$form['xss'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Restrict unsafe HTML by escaping.'),
'#default_value' => $this->settings['xss'],
'#description' => $this
->t('Do not disable this feature unless it interferes with other filters. Disabling it can make your site vulnerable to script injection, unless HTML is already restricted by other filters.'),
];
$options = [];
foreach ($this->storage
->loadMultiple() as $id => $tag) {
$options[$id] = $tag
->label();
}
$form['tags'] = [
'#type' => 'select',
'#title' => $this
->t('Tag set'),
'#empty_value' => '',
'#default_value' => $this->settings['tags'],
'#options' => $options,
'#description' => $this
->t('Without a <a href=":url">tag set</a>, this filter will use all available tags with default settings.', [
':url' => Url::fromRoute('entity.xbbcode_tag_set.collection')
->toString(),
]),
];
if ($collisions = $this->manager
->getDefaultNameCollisions()) {
$form['collisions'] = [
'#theme' => 'item_list',
'#items' => array_map(static function ($x) {
return "[{$x}]";
}, array_keys($collisions)),
'#prefix' => $this
->t('The following default names are each used by multiple plugins. A tag set is needed to assign unique names; otherwise each name will be assigned to one of its plugins arbitrarily.'),
];
}
return $form;
}