public function HtmlPurifierFilter::settingsForm in HTML Purifier 8
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/ HtmlPurifierFilter.php, line 71
Class
- HtmlPurifierFilter
- Plugin annotation @Filter( id = "htmlpurifier", title = @Translation("HTML Purifier"), description = @Translation("Removes malicious HTML code and ensures that the output is standards compliant."), type =…
Namespace
Drupal\htmlpurifier\Plugin\FilterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
if (empty($this->settings['htmlpurifier_configuration'])) {
/* @var $purifier_config \HTMLPurifier_Config */
$purifier_config = \HTMLPurifier_Config::createDefault();
$default_value = Yaml::encode($purifier_config
->getAll());
}
else {
$default_value = $this->settings['htmlpurifier_configuration'];
}
$form['htmlpurifier_configuration'] = [
'#type' => 'textarea',
'#rows' => 50,
'#title' => t('HTML Purifier Configuration'),
'#description' => t('These are the config directives in YAML format, according to the <a href="@url">HTML Purifier documentation</a>', [
'@url' => 'http://htmlpurifier.org/live/configdoc/plain.html',
]),
'#default_value' => $default_value,
'#element_validate' => [
[
$this,
'settingsFormConfigurationValidate',
],
],
];
return $form;
}