FormInterface.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace Drupal\Core\Form;
  3. /**
  4. * Provides an interface for a Form.
  5. *
  6. * @ingroup form_api
  7. */
  8. interface FormInterface {
  9. /**
  10. * Returns a unique string identifying the form.
  11. *
  12. * The returned ID should be a unique string that can be a valid PHP function
  13. * name, since it's used in hook implementation names such as
  14. * hook_form_FORM_ID_alter().
  15. *
  16. * @return string
  17. * The unique string identifying the form.
  18. */
  19. public function getFormId();
  20. /**
  21. * Form constructor.
  22. *
  23. * @param array $form
  24. * An associative array containing the structure of the form.
  25. * @param \Drupal\Core\Form\FormStateInterface $form_state
  26. * The current state of the form.
  27. *
  28. * @return array
  29. * The form structure.
  30. */
  31. public function buildForm(array $form, FormStateInterface $form_state);
  32. /**
  33. * Form validation handler.
  34. *
  35. * @param array $form
  36. * An associative array containing the structure of the form.
  37. * @param \Drupal\Core\Form\FormStateInterface $form_state
  38. * The current state of the form.
  39. */
  40. public function validateForm(array &$form, FormStateInterface $form_state);
  41. /**
  42. * Form submission handler.
  43. *
  44. * @param array $form
  45. * An associative array containing the structure of the form.
  46. * @param \Drupal\Core\Form\FormStateInterface $form_state
  47. * The current state of the form.
  48. */
  49. public function submitForm(array &$form, FormStateInterface $form_state);
  50. }