How to set the id of a dd element in Zend_Form manually?
I have an image element in my Zend_Form.
$dropDownButton = new Zend_Form_Element_Image('image_button');
$dropDownButton->setOptions(array('image'=>'/images/image1.png',
开发者_运维问答 'style'=>'padding-top:20px',
)
);
$this->addElement($dropDownButton);
The above image is serving as some form of 'submit' button. the html output is:
<dd>
<input type="image" style="padding-top: 20px;" alt="" src="/images/image1.png" id="image_button" name="image_button">
</dd>
For all other Zend form elements, I get something like:
<dd id="name-element"></dd>
How can I do the same in case of an Image Zend Form Element?
Is there a way I can set the id?
I did this and it worked:
$dropDownButton->setDecorators(array
(array('ViewHelper'),
array('Errors'),
array('HtmlTag',
array('tag' => 'dd','id'=>'add_drop_down-element'))));
Output is:
<dd id="add_drop_down-element"></dd>
I think $element->setAttrib('id', 'my_id');
will work.
精彩评论