public function TocFilter::settingsForm in TOC filter 8.2
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/ TocFilter.php, line 50 - Contains \Drupal\toc_filter\Plugin\Filter\TocFilter.
Class
- TocFilter
- Provides a filter to display a table of contents.
Namespace
Drupal\toc_filter\Plugin\FilterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$toc_types = TocType::loadMultiple();
foreach ($toc_types as $toc_type) {
$types[$toc_type
->id()] = $toc_type
->label();
}
$form['type'] = [
'#title' => $this
->t('Type'),
'#type' => 'select',
'#options' => $types,
'#default_value' => $this->settings['type'] ?: 'default',
];
$form['auto'] = [
'#title' => $this
->t('Automatically include table of contents'),
'#description' => $this
->t('If set, a table of contents will be added when a <code>[toc]</code> token is not present in the content.'),
'#type' => 'select',
'#options' => [
'' => '',
'top' => $this
->t('At the top of the page'),
'bottom' => $this
->t('At the bottom of the page'),
],
'#default_value' => $this->settings['auto'],
];
$form['block'] = [
'#title' => $this
->t('Display table of contents in a block.'),
'#description' => $this
->t('Please make sure to place the <a href=":href">TOC filter</a> block on your site.', [
':href' => URL::fromRoute('block.admin_display')
->toString(),
]),
'#type' => 'checkbox',
'#default_value' => $this->settings['block'],
];
return $form;
}