Updated to Drupal 8.6.4, which is PHP 7.3 friendly. Also updated HTMLaw library....
[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  * @internal
11  */
12 class ContainerForm extends ForumForm {
13
14   /**
15    * Reusable url stub to use in watchdog messages.
16    *
17    * @var string
18    */
19   protected $urlStub = 'container';
20
21   /**
22    * {@inheritdoc}
23    */
24   public function form(array $form, FormStateInterface $form_state) {
25     // Build the bulk of the form from the parent forum form.
26     $form = parent::form($form, $form_state);
27
28     // Set the title and description of the name field.
29     $form['name']['#title'] = $this->t('Container name');
30     $form['name']['#description'] = $this->t('Short but meaningful name for this collection of related forums.');
31
32     // Alternate description for the container parent.
33     $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.');
34     $this->forumFormType = $this->t('forum container');
35     return $form;
36   }
37
38   /**
39    * {@inheritdoc}
40    */
41   public function buildEntity(array $form, FormStateInterface $form_state) {
42     $entity = parent::buildEntity($form, $form_state);
43     $entity->forum_container = TRUE;
44     return $entity;
45   }
46
47 }