0

I have the following code in my forms.ini file, that is not working (form rendered is still using the default DtDd decorator).

incident.elements.ticket_number.type = "text"
incident.elements.ticket_number.options.label = "Ticket Number"
incident.elements.ticket_number.options.required = true
incident.elements.ticket_number.decorators.elements.decorator = "ViewHelper"
incident.elements.ticket_number.decorators.list_item.decorator = "HtmlTag"
incident.elements.ticket_number.decorators.list_item.options.tag = "li"
incident.elements.ticket_number.decorators.label.decorator = "Label"

Showing output:

<dt id="ticket_number-label">
    <label for="ticket_number" class="required">Ticket Number</label>
</dt>
<dd id="ticket_number-element">
    <input type="text" name="ticket_number" id="ticket_number" value="">
</dd>

However I want it to show:

<li>
    <label for=...>Ticket Number</label>
    <input type="text" name="ticket_number" id="ticket_number" value="">
</li>

what am I doing wrong here?

Aaron Murray
  • 1,920
  • 3
  • 22
  • 38
  • also to note: the Zend_Form decorator settings are working correctly to produce
      {elements}
    , it is just the elements that aren't working
    – Aaron Murray Dec 28 '11 at 18:07

1 Answers1

1

I believe the decorators for the element need to be added as options as well.

See if the following works for you:

incident.elements.ticket_number.type = "text"
incident.elements.ticket_number.options.label = "Ticket Number"
incident.elements.ticket_number.options.required = true
incident.elements.ticket_number.options.decorators.viewhelper.decorator = "ViewHelper"
incident.elements.ticket_number.options.decorators.label.decorator = "Label"
incident.elements.ticket_number.options.decorators.errors.decorator = "Errors"
incident.elements.ticket_number.options.decorators.description.decorator = "Description"
incident.elements.ticket_number.options.decorators.htmltag.decorator = "HtmlTag"
incident.elements.ticket_number.options.decorators.htmltag.options.tag = "li"

Note that I also changed the order of the decorators slightly so that the <label> tag would also be wrapped in the <li> tag. If the label is after the HtmlTag I found it would prepend the input, but was not wrapped in <li>

You will also have to specify the decorators for each form element, otherwise they will use the default form decorators. You could set the above spec to be your default decorator, but then you will also need special decorators for buttons/submit and file inputs.

drew010
  • 68,777
  • 11
  • 134
  • 162
  • Bingo! That was exactly what I was trying to accomplish! I have been google searching for the answer all morning! Thank you very much! – Aaron Murray Dec 28 '11 at 18:57