vietean
vietean

Reputation: 3033

How to add the class name attribute to parent tag of label using Zend_Form_Decorator?

I tried so hard, but I could not make the decorator like below format for my form:

<form>
    <div class="form_wrapper">
        <div class="form_label">
            <!-- {{label}} -->
        </div>
        <div class="form_element">
            <!-- {{element}} -->
        </div>
    </div> <!-- end .form_wrapper -->
    <div class="form_wrapper">
        <div class="form_label">
            <!-- {{label}} -->
        </div>
        <div class="form_element">
            <!-- {{element}} -->
        </div>
    </div> <!-- end .form_wrapper -->
</form>

And When I try to set class is form_label for my decorator:

array('Label', array('tag' => 'div', 'class' => 'form_label'))

It always is:

<div>
    <label class="form_label">Title</label>
</div>

I need to move form_label class inside the label tag to parent element: div tag of it?

How can I do that?

Upvotes: 0

Views: 501

Answers (1)

Ashley
Ashley

Reputation: 5947

Try this for your decorator:

array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form_element')),
array('Label', array('tag' => 'div', 'tagClass'=>'form_label')),
array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form_wrapper'))

The important part is:

'tagClass'=>'form_label'

Look at Zend_Form_Decorator_Label::render() for how it works

Upvotes: 5

Related Questions