tags:

views:

246

answers:

2

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">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.

A: 

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
michal kralik
A: 

You can take out fields that will be repeated into subform. Ids will be made from subform name and element name separated by dash.

Yaroslav