function ForumForm::form

Same name and namespace in other branches
  1. 9 core/modules/forum/src/Form/ForumForm.php \Drupal\forum\Form\ForumForm::form()
  2. 8.9.x core/modules/forum/src/Form/ForumForm.php \Drupal\forum\Form\ForumForm::form()
  3. 10 core/modules/forum/src/Form/ForumForm.php \Drupal\forum\Form\ForumForm::form()

Overrides TermForm::form

1 call to ForumForm::form()
ContainerForm::form in core/modules/forum/src/Form/ContainerForm.php
Gets the actual form array to be built.
1 method overrides ForumForm::form()
ContainerForm::form in core/modules/forum/src/Form/ContainerForm.php
Gets the actual form array to be built.

File

core/modules/forum/src/Form/ForumForm.php, line 34

Class

ForumForm
Base form for forum term edit forms.

Namespace

Drupal\forum\Form

Code

public function form(array $form, FormStateInterface $form_state) {
    // Build the bulk of the form from the parent taxonomy term form.
    $form = parent::form($form, $form_state);
    // Set the title and description of the name field.
    $form['name']['#title'] = $this->t('Forum name');
    $form['name']['#description'] = $this->t('Short but meaningful name for this collection of threaded discussions.');
    // Change the description.
    $form['description']['#description'] = $this->t('Description and guidelines for discussions within this forum.');
    // Re-use the weight field.
    $form['weight'] = $form['relations']['weight'];
    // Remove the remaining relations fields.
    unset($form['relations']);
    // Our parent field is different to the taxonomy term.
    $form['parent']['#tree'] = TRUE;
    $form['parent'][0] = $this->forumParentSelect($this->entity
        ->id(), $this->t('Parent'));
    $form['#theme_wrappers'] = [
        'form__forum',
    ];
    $this->forumFormType = $this->t('forum');
    return $form;
}

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