file FormBase.php

Namespace

Drupal\bootstrap\Plugin\Form
  1. <?php
  2. namespace Drupal\bootstrap\Plugin\Form;
  3. use Drupal\bootstrap\Plugin\PluginBase;
  4. use Drupal\bootstrap\Utility\Element;
  5. use Drupal\Core\Form\FormStateInterface;
  6. /**
  7. * Base form alter class.
  8. *
  9. * @ingroup plugins_form
  10. */
  11. class FormBase extends PluginBase implements FormInterface {
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public function alterForm(array &$form, FormStateInterface $form_state, $form_id = NULL) {
  16. $this->alterFormElement(Element::create($form), $form_state, $form_id);
  17. }
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public function alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {}
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public static function submitForm(array &$form, FormStateInterface $form_state) {
  26. static::submitFormElement(Element::create($form), $form_state);
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public static function submitFormElement(Element $form, FormStateInterface $form_state) {}
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public static function validateForm(array &$form, FormStateInterface $form_state) {
  36. static::validateFormElement(Element::create($form), $form_state);
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public static function validateFormElement(Element $form, FormStateInterface $form_state) {}
  42. }

Classes

Name Description
FormBase Base form alter class.