views:

160

answers:

1

I have set the form decorators in this way:

    <?php

    $this->setElementDecorators(array(
            'Label',
            array(array('labelTd' => 'HtmlTag'), array('tag' => 'td', 'class' => 'name')),
            array(array('elemTdOpen' => 'HtmlTag'), array('tag' => 'td', 'class' => 'form','openOnly' => true, 'placement' => 'append')),
            'ViewHelper',               
            'Errors',           
            array(array('elemTdClose' => 'HtmlTag'), array('tag' => 'td', 'closeOnly' => true, 'placement' => 'append')),
            array(array('row' => 'HtmlTag'), array('tag' => 'tr', 'class' => 'question')),
    ));

    $submit->setDecorators(array('ViewHelper',
            array(array('data' => 'HtmlTag'),  array('tag' =>'td', 'class'=> 'element')),
            array(array('emptyrow' => 'HtmlTag'),  array('tag' =>'td', 'class'=> 'element', 'placement' => 'PREPEND')),
            array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
            ));

    $this->setDecorators(array(
            'FormElements',
            array('HtmlTag', array('tag' => 'table', 'class' => 'simpleform')),
            'Form'
        ));

It outputs a simple table

<table class="simpleform">
<tbody>
    <tr class="question">
        <td class="name">
            <label class="required" for="email">Your email</label>
        </td>
        <td class="form">
            <input type="text" value="asasd" id="email" name="email">
            <ul class="errors">
                <li>'asasd' is no valid email address in the basic format local-part@hostname
                </li>
                <li>Information not found
                </li>
            </ul>
        </td>
    </tr>
    <tr>
        <td class="element"></td>
        <td class="element">
            <input type="submit" value="Send" id="submit" name="submit">
        </td>
    </tr>
</tbody>
</table>

I would like to wrap ul.errors to TD and put it as the third cell. Like that:

        <tr class="question">
        <td class="name">
            <label class="required" for="email">Your email</label>
        </td>
        <td class="form">
            <input type="text" value="asasd" id="email" name="email">
        </td>
        <td>
            <ul class="errors">
                <li>'asasd' is no valid email address in the basic format local-part@hostname
                </li>
                <li>Information not found
                </li>
            </ul>
        </td>
    </tr>

and.. how to do that? :)

+1  A: 

I suggest you create your own Errors decorator which will do what you need.
You can for example set it up to output

    </td>
    <td>
        <ul class="errors">
            <li>'asasd' is no valid email address in the basic format local-part@hostname
            </li>
            <li>Information not found
            </li>
        </ul>

If you know the errors will always be part of a table within <td></td> tags.

In general, no framework is flexible enough to cover all scenarios and frameworks shouldn't be slowing you down in development. If you cannot do something using framework and you cannot extend the framework to satisfy your requirement, go around it and don't use it in this particular case. It's not said all the forms have to use Zend_Form :)

michal kralik