I would like to wrap form elements with labels as such
<label for="email">E-mail <input type="text" name="email" id="email" /></label>
The only option I could find is to alter the placement; however it only accepts ‘prepend’ and ‘append’:
<!-- prepend -->
<label for="email">E-mail</label> <input type="text" name="email" id="email" />
<!-- append -->
<input type="text" name="email" id="email" /> <label for="email">E-mail</label>
That is not what I am after. I could alter the Zend_Form_Decorator_Label class, but that is the last alternative.
This doesn’t seem to be possible unfortunately, you’ll probably have to write a custom decorator. It should be pretty simple, though.
Please note im just going to write this here, it’s untested but based off another decorator so it should work with little/no modification
Now if you add the correct prefix to your form.
You should be able to use this to wrap your input (FormElement decorator) in a label tag.
Sorry I haven’t had a chance to actually test this but given how my other decorators work. It should be fine.
EDIT: Thanks for pointing out that the label text wasn’t being rendered gnarf. This is now fixed.