【问题标题】:Zend Form_element inside or appended to html tags containing textZend Form_element 内部或附加到包含文本的 html 标记
【发布时间】:2011-05-26 12:42:53
【问题描述】:

在 Zend_Form 中是否可以使用装饰器在元素前添加一对包含文本的 html 标签?如何?

例如:

<div>My text inside html tags prepended..</div><input type='text'>

已编辑:

如果我想在一对仍然包含文本的 html 标签中放置一个表单元素呢?

例如

<div>
 This div is containing both my custom text and my form element: 
 <input type='text'>
</div>

谢谢

卢卡

【问题讨论】:

    标签: php zend-framework zend-form-element zend-decorators html


    【解决方案1】:

    随便用

     $element->setDescription("My text");
    

    如果需要,您也可以使用标签。

    如果您需要,您也可以使用 HtmlTag 帮助器供您的装饰器使用,并将位置设置为 PREPEND。

    编辑

    $elementDecorators = array(
                                    'ViewHelper',
                                    array('Label', array( 'tag' => 'span', 'placement' => 'prepend')),
                                    array('Description', array( 'tag' => 'div', 'placement' => 'append','class'=>'eDesc')),                                
                                    array('HtmlTag', array( 'tag' => 'div', 'class'=>'userElement'))
    );
    
    $element->setDecorators( $elementDecorators);
    

    【讨论】:

    • 更新了一些可以添加的示例选项。
    猜你喜欢
    • 2020-12-07
    • 1970-01-01
    • 1970-01-01
    • 2018-03-04
    • 2020-01-19
    • 1970-01-01
    • 2017-01-24
    • 2011-11-07
    • 1970-01-01
    相关资源
    最近更新 更多