Item.php 986 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace Drupal\Core\Render\Element;
  3. /**
  4. * Provides a display-only form element with an optional title and description.
  5. *
  6. * Note: since this is a read-only field, setting the #required property will do
  7. * nothing except theme the form element to look as if it were actually required
  8. * (i.e. by placing a red star next to the #title).
  9. *
  10. * @FormElement("item")
  11. */
  12. class Item extends FormElement {
  13. /**
  14. * {@inheritdoc}
  15. */
  16. public function getInfo() {
  17. return [
  18. // Forms that show author fields to both anonymous and authenticated users
  19. // need to dynamically switch between #type 'textfield' and #type 'item'
  20. // to automatically take over the authenticated user's information.
  21. // Therefore, we allow #type 'item' to receive input, which is internally
  22. // assigned by Form API based on the #default_value or #value properties.
  23. '#input' => TRUE,
  24. '#markup' => '',
  25. '#theme_wrappers' => ['form_element'],
  26. ];
  27. }
  28. }