6.6. View Decoration

The Solar_View_Helper_Form helper lets you decorate the element output in varying structures:

  • The default decorateAsDlList() method decorates all the elements as parts of a <dl> list, where the element labels are are in <dt> tags, and the element values are in <dd> tags.

  • The decorateAsTable() method puts all the elements in a <table>. Each label/value pair is wrapped in a <tr>, the labels are wrapped in <th> tags, and the element values are wrapped in <td> tags.

  • The decorateAsDivs() method puts all the elements in nested <div> tags. The list as a whole is wrapped in a <div> tag, and each label/value pair is wrapped in another <div> tag.

  • Finally, the decorateAsPlain() removes all structural decoration tags.

All you need to do is call the right decorator method and the form helper will do the rest. Below is the same code as in the blog demo edit.php view, with one extra decorator call added.

    echo $this->form()             
              ->decorateAsDivs()  // use <div>s instead of <dl> tags

The resulting output looks like this:

<form action="/blog/edit/1" method="post" enctype="multipart/form-data">
    <div class="list">
        <div class="blog-status">
            <label for="blog-status" class="blog-status">Status</label>
            <select name="blog[status]" id="blog-status" class="input-select blog-status">
                <option value="draft" label="draft">draft</option>
                <option value="public" label="public" selected="selected">public</option>
        <div class="blog-title require">
            <label for="blog-title" class="blog-title require">Title</label>
            <input type="text" name="blog[title]" value="Public Blog Entry" 
                maxlength="63" size="60" id="blog-title" class="input-text 
                blog-title require"
        <div class="blog-body">
            <label for="blog-body" class="blog-body">Body</label>
            <textarea name="blog[body]" rows="18" cols="60" id="blog-body" 
                class="input-textarea blog-body">First post!</textarea>

        <div class="process-save">
            <input type="submit" name="process" value="Save" id="process-save"
                class="input-submit process-save"