Current Record: fieldgroup_template #51

Using a custom template for a field group on the edit form Table of Contents Using a custom template for a field group on the edit form ...

Current Record: fieldgroup_template #51

Using a custom template for a field group on the edit form Table of Contents Using a custom template for a field group on the edit form ...

fieldgroup_template

[Permalink]

Using a custom template for a field group on the edit form

Xataface allows you to partition your fields into groups so that similar fields are grouped together on the edit form. The default layout of the fields remains simply vertical, but you can customize this layout (on a per-group basis) by creating a custom template and then assigning this template to the field group with the template directive.

Example

For example, in your fields.ini file if you wanted to group your address fields together you might have:

[fieldgroup:address]
    label="Address Information"
    template="AddressInformationGroup.html"

[address_1]
    group=address

[city]
    group=address

[state]
    group=address

Then you would add the a template named AddressInformationGroup.html to your application's templates directory to display how the fields are laid out:

<table width="100%">
    <tr><th>Address 1:</th>
    <td>{$elements.address_1.html}</td>

    <th>City:</th>
    <td>{$elements.city.html}</td>

    <th>State:</th>
    <td>{$elements.state.html}</td>
    </tr>
</table>
This would display all of the fields in this group in a single row (horizontally) instead of vertically.

Note that this is an over-simplified example that doesn't take account for display error messages, required notices, grouped fields, and other information that you can obtain from the {$elements} array.

blog comments powered by Disqus
Powered by Xataface
(c) 2005-2024 All rights reserved