Version 1
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / Form / FormBase.php
1 <?php
2 /**
3  * @file
4  * Contains \Drupal\bootstrap\Plugin\Form\FormBase.
5  */
6
7 namespace Drupal\bootstrap\Plugin\Form;
8
9 use Drupal\bootstrap\Plugin\PluginBase;
10 use Drupal\bootstrap\Utility\Element;
11 use Drupal\Core\Form\FormStateInterface;
12
13 /**
14  * Base form alter class.
15  *
16  * @ingroup plugins_form
17  */
18 class FormBase extends PluginBase implements FormInterface {
19
20   /**
21    * {@inheritdoc}
22    */
23   public function alterForm(array &$form, FormStateInterface $form_state, $form_id = NULL) {
24     $this->alterFormElement(Element::create($form), $form_state, $form_id);
25   }
26
27   /**
28    * {@inheritdoc}
29    */
30   public function alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {}
31
32   /**
33    * {@inheritdoc}
34    */
35   public static function submitForm(array &$form, FormStateInterface $form_state) {
36     static::submitFormElement(Element::create($form), $form_state);
37   }
38
39   /**
40    * {@inheritdoc}
41    */
42   public static function submitFormElement(Element $form, FormStateInterface $form_state) {}
43
44   /**
45    * {@inheritdoc}
46    */
47   public static function validateForm(array &$form, FormStateInterface $form_state) {
48     static::validateFormElement(Element::create($form), $form_state);
49   }
50
51   /**
52    * {@inheritdoc}
53    */
54   public static function validateFormElement(Element $form, FormStateInterface $form_state) {}
55
56 }