function BookSettingsForm::buildForm

Same name in other branches
  1. 9 core/modules/book/src/Form/BookSettingsForm.php \Drupal\book\Form\BookSettingsForm::buildForm()
  2. 8.9.x core/modules/book/src/Form/BookSettingsForm.php \Drupal\book\Form\BookSettingsForm::buildForm()
  3. 11.x core/modules/book/src/Form/BookSettingsForm.php \Drupal\book\Form\BookSettingsForm::buildForm()

Overrides ConfigFormBase::buildForm

File

core/modules/book/src/Form/BookSettingsForm.php, line 33

Class

BookSettingsForm
Configure book settings for this site.

Namespace

Drupal\book\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
    $types = node_type_get_names();
    $form['book_allowed_types'] = [
        '#type' => 'checkboxes',
        '#title' => $this->t('Content types allowed in book outlines'),
        '#config_target' => new ConfigTarget('book.settings', 'allowed_types', toConfig: static::class . '::filterAndSortAllowedTypes'),
        '#options' => $types,
        '#description' => $this->t('Users with the %outline-perm permission can add all content types.', [
            '%outline-perm' => $this->t('Administer book outlines'),
        ]),
        '#required' => TRUE,
    ];
    $form['book_child_type'] = [
        '#type' => 'radios',
        '#title' => $this->t('Content type for the <em>Add child page</em> link'),
        '#config_target' => 'book.settings:child_type',
        '#options' => $types,
        '#required' => TRUE,
    ];
    return parent::buildForm($form, $form_state);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.