Version 1
[yaffs-website] / web / core / modules / forum / src / Form / ContainerForm.php
1 <?php
2
3 namespace Drupal\forum\Form;
4
5 use Drupal\Core\Form\FormStateInterface;
6
7 /**
8  * Base form for container term edit forms.
9  */
10 class ContainerForm extends ForumForm {
11
12   /**
13    * Reusable url stub to use in watchdog messages.
14    *
15    * @var string
16    */
17   protected $urlStub = 'container';
18
19   /**
20    * {@inheritdoc}
21    */
22   public function form(array $form, FormStateInterface $form_state) {
23     $taxonomy_term = $this->entity;
24     // Build the bulk of the form from the parent forum form.
25     $form = parent::form($form, $form_state, $taxonomy_term);
26
27     // Set the title and description of the name field.
28     $form['name']['#title'] = $this->t('Container name');
29     $form['name']['#description'] = $this->t('Short but meaningful name for this collection of related forums.');
30
31     // Alternate description for the container parent.
32     $form['parent'][0]['#description'] = $this->t('Containers are usually placed at the top (root) level, but may also be placed inside another container or forum.');
33     $this->forumFormType = $this->t('forum container');
34     return $form;
35   }
36
37   /**
38    * {@inheritdoc}
39    */
40   public function buildEntity(array $form, FormStateInterface $form_state) {
41     $entity = parent::buildEntity($form, $form_state);
42     $entity->forum_container = TRUE;
43     return $entity;
44   }
45
46 }