Render a single element in a form

  • Views Views: 10,358
  • Last updated Last updated:
  • In your form templates, Elements are rendered in the sub template default_group.php

    PHP:

    $this->Elements;

    Is an array of element objects, keyed on the element name.
    By default the default_group.php sub template loops over the element's and renders them all out.

    Often in a custom template we want to get a specific element, so if I wanted to access the element named 'age' I could do:

    PHP:

    $ageElement = $this->Elements['age'];

    Each element is an object with a series of properties:
    • plugin - the element's plugin e.g. 'field'
    • id - Unique reference, e.g. 'tablename___name'
    • element - the HTML field e.g. <input .... />
    • label_raw - the label as plain text
    • label - the label text wrapped in its <label/> tag
    • value - the value assigned to the element
    • error - any error message generated from a fail Validation
    • column (fabrik 3.0 only) css used to build group columns
    To output the element's value we can write this PHP:
    PHP:

    echo $ageElement->value;
Back
Top