zendframework/zf2 — pull request #4677 by stefanotorresi (2013-06-17 15:41:30+00:00)
Title: Add Form\Element labelOptions property w/ implemented use case

Having a `labelOptions` array of dedicated properties for the form labels makes custom rendering of the form a bit easier.

One use case is the possibilty to disable HTML escaping of the label text.

A common use case for this is an hyper link inside the label, which pretty much any html form with a 'privacy terms' checkbox needs.

Since `Form\View\Helper\FormRow` view helper escapes the label content, the only way of doing this at the moment is using custom view templates.

That denies the purpose of `Form\View\Helper\Form` and `Form\View\Helper\FormRow`.

This PR adds `labelOptions` property and accessors to the `Form\Element` class, and implements the `disable_escape` option in `Form\View\Helper\FormRow`.

I reckon that adding an array to the `Form\Element` class just to handle a view helper option may seem a bit overkill in this case, but I'm looking from a wider angle: being able to tie custom options to the form element label itself gives much more flexibility when developing custom view templates and helpers; the example above is just the simplest I had to deal with.