Freeform Documentation

Learn the basics, and get to know Freeform inside and out.

Freeform 1.x Docs

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 }}

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>

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 %}

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 %}