zend-framework - 如何手动设置 Zend_Form 中 dd 元素的 id?

标签 zend-framework zend-form zend-form-element zend-form-sub-form

我的 Zend_Form 中有一个图像元素。

$dropDownButton = new Zend_Form_Element_Image('image_button');
$dropDownButton->setOptions(array('image'=>'/images/image1.png',
                                'style'=>'padding-top:20px',
                                )
                                );
$this->addElement($dropDownButton);

上图充当某种形式的“提交”按钮。 html 输出为:

<dd>
<input type="image" style="padding-top: 20px;" alt="" src="/images/image1.png" id="image_button" name="image_button">
</dd>

对于所有其他 Zend 表单元素,我得到如下内容:

 <dd id="name-element"></dd>

如果是 Image Zend Form 元素,我该如何做同样的事情?

有办法设置id吗?

最佳答案

我这样做了并且有效:

$dropDownButton->setDecorators(array
                                 (array('ViewHelper'),
                                 array('Errors'),
                                 array('HtmlTag',
                                        array('tag' => 'dd','id'=>'add_drop_down-element'))));

输出是:

<dd id="add_drop_down-element"></dd>

关于zend-framework - 如何手动设置 Zend_Form 中 dd 元素的 id?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2149760/

相关文章:

php - Zend DB SELECT 与数据库中的 JOIN

forms - 如何在 Zend Framework 2 中实现表单预览页面?

php - Zend Forms - 元素 ID 修改以允许重复使用

zend-framework - Zend Framework:使用数组符号形式的表单元素

php - Zend_Form_Element_File 和 "File exceeds the defined ini size"问题

mysql - Zend_Db last_insert_id 返回超大数

facebook - Zend Framework - 添加属性不起作用的元标记

zend-framework - 禅德 : index generation and the pros and cons of Zend_Search_Lucene

php - Zend 框架 : Require one out of three values

zend-framework - zend 表单电子邮件验证