我有:
$this->addElement('select', 'type', array(
'label' => 'Banner type',
'required' => true,
'multiOptions' => array(
'' => 'Please select',
'1' => 'Image',
'3' => 'Flash',
'4' => 'Html'
),
'value' => '',
));
但是在呈现选定的 dropdown
时,它具有我不想要的 id = "type"
属性。我正在用 JavaScript 克隆它,但在发生所有事件后它无法正常工作。
最佳答案
您最好修改您的 javascript(仅在克隆元素时更改 id)。
如果你想用 ZF 改变你的表单元素的结构你必须创建你自己的扩展 Zend_Form_Element_Select 的选择元素,然后创建你自己的扩展 Zend_View_Helper_FormSelect 的 formSelect View 助手并覆盖 formSelect()
方法.然后在下面查看我的评论:
$xhtml = '<select'
. ' name="' . $this->view->escape($name) . '"'
. ' id="' . $this->view->escape($id) . '"' // remove this line
. $multiple
. $disabled
. $this->_htmlAttribs($attribs)
. ">\n ";
关于javascript - 从 Zend Form 元素中删除 id 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28300651/