theming-example-text-form.html.twig

Same filename in other branches
  1. 4.0.x modules/theming_example/templates/theming-example-text-form.html.twig

Template file for the theming example text form.

Available custom variables:

  • $text_form: A string containing the pre-rendered form.
  • $text_form_content: An array of form elements keyed by the element name.

The default example below renders the entire form and its form elements in a default order provided by Drupal.

Alternatively, you may print each form element in the order you desire, adding any extra html markup you wish to decorate the form like this:

<?php print $text_form_content['element_name']; ?>

The following snippet will print the contents of the $text_form_content array, hidden in the source of the page, for you to discover the individual element names.

<?php print '<!--' . print_r($text_form_content, TRUE) . '-->'; ?>

File

modules/theming_example/templates/theming-example-text-form.html.twig

View source
  1. {#
  2. /**
  3. * @file
  4. * Template file for the theming example text form.
  5. *
  6. * Available custom variables:
  7. * - $text_form: A string containing the pre-rendered form.
  8. * - $text_form_content: An array of form elements keyed by the element name.
  9. *
  10. * The default example below renders the entire form and its form elements in
  11. * a default order provided by Drupal.
  12. *
  13. * Alternatively, you may print each form element in the order you desire,
  14. * adding any extra html markup you wish to decorate the form like this:
  15. *
  16. * <?php print $text_form_content['element_name']; ?>
  17. *
  18. * The following snippet will print the contents of the $text_form_content
  19. * array, hidden in the source of the page, for you to discover the individual
  20. * element names.
  21. *
  22. * <?php print '<!--' . print_r($text_form_content, TRUE) . '-->'; ?>
  23. */
  24. #}
  25. <!-- theming-example-text-form template -->
  26. <div class="container-inline">
  27. {{ text_form }}
  28. </div>
  29. <!-- /theming-example-text-form template -->