You are here

webform-progress-bar.html.twig in Webform 6.x

Same filename and directory in other branches
  1. 8.5 templates/webform-progress-bar.html.twig

Default theme implementation for webform wizard progress bar.

Available variables:

  • webform: A webform.
  • pages: Associative array of wizard pages.
  • progress: Array of wizard progress containing page titles.
  • current_page: Current wizard page key.
  • current_index: The current wizard page index.
  • max_pages: Maximum number of pages to be displayed.

File

templates/webform-progress-bar.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation for webform wizard progress bar.
  5. *
  6. * Available variables:
  7. * - webform: A webform.
  8. * - pages: Associative array of wizard pages.
  9. * - progress: Array of wizard progress containing page titles.
  10. * - current_page: Current wizard page key.
  11. * - current_index: The current wizard page index.
  12. * - max_pages: Maximum number of pages to be displayed.
  13. *
  14. * @see template_preprocess_webform_progress_bar()
  15. *
  16. * @ingroup themeable
  17. */
  18. #}
  19. {{ attach_library('webform/webform.progress.bar') }}
  20. {% spaceless %}
  21. {% if progress|length < max_pages %}
  22. <ol class="webform-progress-bar" data-steps="{{ progress|length }}">
  23. {% for index, page in progress %}
  24. {%
  25. set classes = [
  26. 'webform-progress-bar__page',
  27. index < current_index ? 'webform-progress-bar__page--done',
  28. index == current_index ? 'webform-progress-bar__page--current',
  29. ]
  30. %}
  31. <li{{ attributes.setAttribute('data-webform-page', page.name).setAttribute('class', '').addClass(classes) }}>
  32. <b>{{ page.title }}</b>{% if (loop.first or loop.last) %}<span></span>{% endif %}
  33. </li>{% endfor %}
  34. </ol>
  35. {% endif %}
  36. {% endspaceless %}