Displaying Container Rule Options to the User

Finally we must create a template that displays the options to the user. This template uses Smarty Template Engine syntax, and belongs in the ./templates/index.tpl file in your container driver directory.

This template should consists of a separate {field}{/field} block for each user-definable option. The {field} block accepts a number of different arguments, including the title, error key and help value. The error key corresponds to the first argument passed to addError() when processing the values. If you set the required parameter to true, a red asterisk will appear besides the field title.

The data returned from getEditorData() is available in the template in the $fp->data variable. The following template demonstrates how to use this data so the user can choose a location.

Example 3.4. Displaying container rule options to the user

{field title='Location'
       required=true
       error='location'
       help='Select the location to display weather for'}

    <select name="location">
        <option value=""></option>
        {html_options values=$fp->data.locations 
                      output=$fp->data.locations 
                      selected=$fp->get('location')}
    </select>

{/field}