FormElementInterface.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Drupal\Core\Render\Element;
  3. use Drupal\Core\Form\FormStateInterface;
  4. /**
  5. * Provides an interface for form element plugins.
  6. *
  7. * Form element plugins are a subset of render elements, specifically
  8. * representing HTML elements that take input as part of a form. Form element
  9. * plugins are discovered via the same mechanism as regular render element
  10. * plugins. See \Drupal\Core\Render\Element\ElementInterface for general
  11. * information about render element plugins.
  12. *
  13. * @see \Drupal\Core\Render\ElementInfoManager
  14. * @see \Drupal\Core\Render\Element\FormElement
  15. * @see \Drupal\Core\Render\Annotation\FormElement
  16. * @see plugin_api
  17. *
  18. * @ingroup theme_render
  19. */
  20. interface FormElementInterface extends ElementInterface {
  21. /**
  22. * Determines how user input is mapped to an element's #value property.
  23. *
  24. * @param array $element
  25. * An associative array containing the properties of the element.
  26. * @param mixed $input
  27. * The incoming input to populate the form element. If this is FALSE,
  28. * the element's default value should be returned.
  29. * @param \Drupal\Core\Form\FormStateInterface $form_state
  30. * The current state of the form.
  31. *
  32. * @return mixed
  33. * The value to assign to the element.
  34. */
  35. public static function valueCallback(&$element, $input, FormStateInterface $form_state);
  36. }