Thanh Nguyen
Thanh Nguyen

Reputation: 5352

Zend Form Decorators issue

*I speak English not well. So i'm going to post the code now.*

Form code:

protected $elementDecorators = array('ViewHelper','Errors','Description','Label',
            array('HtmlTag',array('tag' => 'div','class' => '_wrapperElement')          
            ));

    public function init(){
        $this->addElement('text','mytext',array(
        'class' => '_inputText',
        'label' => 'Mytext',
        'required' => true,
        'decorators' => $this->elementDecorators
        ));

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

    }

Output:

<form method="post" action="" enctype="application/x-www-form-urlencoded">
    <div class="_formWrapper">
        <div class="_wrapperElement">
            <label class="required" for="mytext">Mytext</label>
            <input type="text" class="_inputText" value="" id="mytext" name="mytext">    
        </div>
    </div>
</form>

Now i want a div wraps Label and Input element like this:

<form method="post" action="" enctype="application/x-www-form-urlencoded">
    <div class="_formWrapper">
        <div class="_wrapperElement">
            <div class="_wrapperLabel">
                <label class="required" for="mytext">Mytext</label>
            </div>
            <div class="_wrapperInput">
                <input type="text" class="_inputText" value="" id="mytext" name="mytext">    
            </div>
        </div>
    </div>
</form>

How to do that?

I tried many times but i can't do it.

Thanks!

Upvotes: 0

Views: 72

Answers (2)

Mr Coder
Mr Coder

Reputation: 8196

protected $elementDecorators = array('ViewHelper','Errors','Description', array('Label', array('tag' => 'div', 'class' => '_wrapperLabel')
        ),
            array('HtmlTag',array('tag' => 'div','class' => '_wrapperInput')          
            ));

Upvotes: 1

Thanh Nguyen
Thanh Nguyen

Reputation: 5352

i found the solution that render decorators to ViewScript.

Upvotes: 0

Related Questions