frgtv10
frgtv10

Reputation: 5450

Zend Form Decorators for special table

how can i get this table from my ZEND_FORM?

<table>
    <tr>
        <th>label 1</th>
        <th>label 2</th>
    </tr>
    <tr>
        <td>form element 1</td>
        <td>form element 2</td>
    </tr>
</table>

This is what I have. But this is not correct.

$kinder_decorators = array(
        'ViewHelper', 
        'Errors',

        array('Label', array('tag' => 'th')),
        array(array('data' => 'HtmlTag'), array('tag' => 'td'))


    );

Can anybody help please?

BR Matt

Upvotes: 0

Views: 350

Answers (2)

Decent Dabbler
Decent Dabbler

Reputation: 22783

You will need to use a ViewScript decorator on the whole form I'm afraid. The ViewScript decorator offers more flexibility for more complex layouts of form elements.

See my answer here for a small example. If it's unclear, hit me up with a comment, and I'll expand a little on it here.

Upvotes: 2

Mr Coder
Mr Coder

Reputation: 8186

You can't achieve this type of structure . Since its not possible to wrap two different labels inside same row and two different form element inside another row . Your markup is incorrect btw you should be doing

<tr><td>label1</td><td>form element 1</td></tr>
<tr><td>label2</td><td>form element 2</td></tr>

$kinder_decorators = array(
        'ViewHelper', 
        'Errors',
array(array('content' => 'HtmlTag'), array('tag' => 'td'))
array('Label', array('tag' => 'th')),
array(array('data' => 'HtmlTag'), array('tag' => 'tr'))


    );

Upvotes: 0

Related Questions