You are here

public function ForumForm::form in Drupal 10

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

Gets the actual form array to be built.

Overrides TermForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

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;
}