views:

92

answers:

2

Hello, 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?

A: 

I think $element->setAttrib('id', 'my_id'); will work.

robertbasic
I tried that and it did not set the id of the <dd> element.It however did change the id of the <input> tag inside, although thats not what i want.
Mallika Iyer
ah sorry, I misunderstood your question. For what you want, your solution is the correct one :)
robertbasic
A: 

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>
Mallika Iyer