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 Form Builder. It also contains the index of the page and its label.
Properties
The following properties are available for use:
index
The index of the page (Starts from 0
).
label
Output the label of the page.
Methods
The following methods are available for use:
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
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
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
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
2
3
4
5
6
7
8
9
How to display the total number of pages in a form:
{{ form.pages|length }}
1