开发者

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">&nbsp;</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">&nbsp;</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">&nbsp;</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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜