Now imagine a form with a hundred checkboxes. Sure, you can pre-check all of them or leave them empty, but it would be much easier for the user to have a "select all" and "select none" buttons.
For more efficiency, it's better to have one for each set of checkboxes, and there's nothing better than to put these links as a decorator to the form element containing the checkboxes.
$form_element = new Zend_Form_Element_MultiCheckbox(
'name',
array(
'description' => '<a href="javascript: void();">Select all</a> <a href="javascript: void();">Select none</a>'
)
);
Now that's nice, but instead of having links, the HTML code has been escaped and that's of no use at all.
There's an easy trick to this: just set the decorators!
'decorators' => array(
'ViewHelper',
array(
'Description',
array('escape' => FALSE)
),
'FormElements',
'Form'
)
The important trick is to set the escape value to false, so that the HTML characters won't be converted.
And there we have it, two beautiful links that will same users a lot of hassle.