FormInterface.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. * @return string
  13. * The unique string identifying the form.
  14. */
  15. public function getFormId();
  16. /**
  17. * Form constructor.
  18. *
  19. * @param array $form
  20. * An associative array containing the structure of the form.
  21. * @param \Drupal\Core\Form\FormStateInterface $form_state
  22. * The current state of the form.
  23. *
  24. * @return array
  25. * The form structure.
  26. */
  27. public function buildForm(array $form, FormStateInterface $form_state);
  28. /**
  29. * Form validation handler.
  30. *
  31. * @param array $form
  32. * An associative array containing the structure of the form.
  33. * @param \Drupal\Core\Form\FormStateInterface $form_state
  34. * The current state of the form.
  35. */
  36. public function validateForm(array &$form, FormStateInterface $form_state);
  37. /**
  38. * Form submission handler.
  39. *
  40. * @param array $form
  41. * An associative array containing the structure of the form.
  42. * @param \Drupal\Core\Form\FormStateInterface $form_state
  43. * The current state of the form.
  44. */
  45. public function submitForm(array &$form, FormStateInterface $form_state);
  46. }