You are here

public function CollapseText::settingsForm in Collapse Text 2.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/Filter/CollapseText.php \Drupal\collapse_text\Plugin\Filter\CollapseText::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/CollapseText.php, line 28

Class

CollapseText
Provides a filter to display Collapsible text blocks.

Namespace

Drupal\collapse_text\Plugin\Filter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $form['default_title'] = [
    '#type' => 'textfield',
    '#title' => t('Default title'),
    '#description' => t('If no title is supplied for a section, use this as the default. This may not be empty. The original default title is "@default_title".', [
      '@default_title' => COLLAPSE_TEXT_DEFAULT_TITLE,
    ]),
    '#default_value' => isset($this->settings['default_title']) ? $this->settings['default_title'] : COLLAPSE_TEXT_DEFAULT_TITLE,
    '#required' => TRUE,
  ];
  $form['form'] = [
    '#type' => 'checkbox',
    '#title' => t('Surround text with an empty form tag'),
    '#description' => t('Collapse text works by generating <details> tags. To validate as proper HTML, these need to be within a <form> tag. This option allows you to prevent the generation of the surrounding form tag. You probably do not want to change this.'),
    '#default_value' => isset($this->settings['form']) ? $this->settings['form'] : 1,
  ];
  return $form;
}