Prepending form name, subform name to id of zend dojo form
I am using Zend Form and Dojo. I have a whole bunch of ids that are identical. If you look at the following code you can see my current look :
<dt id="addElement-label"> </dt><dd id="addElement-element"> <button name="createEventForm[categoryDetail][addElement]" id="createEventForm-categoryDetail-addElement" type="button"&g开发者_如何学运维t;addElement</button></dd>
Here is what I would like it to look like
<dt id="createEventForm-categoryDetail-addElement-label"> </dt><dd id="createEventForm-categoryDetail-addElement-element"> <button name="createEventForm[categoryDetail][addElement]" id="createEventForm-categoryDetail-addElement" type="button">addElement</button></dd>
I want to do this as currently this created quite a few identical Ids and that is causing other issues.
If you want to have custom IDs for elements, you need to use your own decorators.
The default DtDdWrapper returns the "standard IDs"
// Zend/Form/Decorator/DtDdWrapper.php line 60-61
return '<dt id="' . $elementName . '-label"> </dt>' .
'<dd id="' . $elementName . '-element">' . $content . '</dd>';
I would suggest either
- extend the class and overload the render() function or
- create and use your own, custom decorator for
Zend_Form_Element
You can take out fields that will be repeated into subform. Ids will be made from subform name and element name separated by dash.
精彩评论