This document is for an older version of

Freeform

.

View latest version →

Page object

The Page object contains all of the Rows assigned to it in the Composer. It also contains the index of the page and its label.

Properties

  • index #
    • The index of the page (Starts from 0).
  • label #
    • Output the label of the page.

Methods

  • getRows() #
    • Use this to iterate over all Rows in this page.
    • You can also just iterate over the Page object to yield the same results (examples provided below).

Usage in Templates

Render the page label and its index:

{{ form.currentPage.label }}
{{ form.currentPage.index }}
1
2

Render all form pages and add a class to the currently shown page:

<ul>
  {% for page in form.pages %}
    <li>
      {% if form.currentPage.index == page.index %}
        <a href="javascript:;">{{ page.label }}</a>
      {% else %}
        {{ page.label }}
      {% endif %}
    </li>
  {% endfor %}
</ul>
1
2
3
4
5
6
7
8
9
10
11

Iterate through all rows and its fields of the current page:

{% for row in form.currentPage %}
  <div class="row">
    {% for field in row %}
      <div class="field">
        {{ field.label }}
      </div>
    {% endfor %}
  </div>
{% endfor %}
1
2
3
4
5
6
7
8
9

Iterating over the form yields the same results:

{% for row in form %}
  <div class="row">
    {% for field in row %}
      <div class="field">
        {{ field.label }}
      </div>
    {% endfor %}
  </div>
{% endfor %}
1
2
3
4
5
6
7
8
9