首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Zend Form Decorator问题

Zend Form Decorator问题
EN

Stack Overflow用户
提问于 2013-03-24 12:36:08
回答 2查看 69关注 0票数 0

*我的英语说得不好。所以我要发布代码now.*

表格代码:

代码语言:javascript
复制
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'));

    }

输出:

代码语言:javascript
复制
<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>

现在,我需要一个div包装标签和输入元素,如下所示:

代码语言:javascript
复制
<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>

怎么做?

我试过很多次了,但我做不到。

谢谢!

EN

回答 2

Stack Overflow用户

发布于 2013-03-24 18:28:23

代码语言:javascript
复制
protected $elementDecorators = array('ViewHelper','Errors','Description', array('Label', array('tag' => 'div', 'class' => '_wrapperLabel')
        ),
            array('HtmlTag',array('tag' => 'div','class' => '_wrapperInput')          
            ));
票数 1
EN

Stack Overflow用户

发布于 2013-03-24 18:03:46

我找到了将装饰器呈现给ViewScript的解决方案。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15598524

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档