zendframework/zf2 — pull request #1468 by mwillbanks (2012-06-08 18:53:39+00:00)
Title: FormElementErrors Helper: Attributes defaults and allow on invoke

Why:
There are times when you might want to use a helper as an object:
$this->formElementErrors()
->setAttributes(array('class' => 'error'))
->setMessageOpenFormat('')
->setMessageCloseString('

')
->setMessageSeparatorString('')
->render($elment);

Othertimes, you may want to set default attributes, message open format, close string and separator string via DI.

Lastly, there are times when you want to overwrite the default attributes quickly, so:
$this->formElementErrors($element, array('class' => 'youbrokeit');

Changes:
Added new protected attribute $attributes
Added methods for getters and setters
Changed __invoke to add optional $attributes parameter (consistent with the render method)
Changed __invoke to have an element be optional in the event you wanted to return the helper object to chain

Tests:
* Added test to check attributes via invoke
* Added test to check default attributes can be overwritten
* Added test to check invoke can return an object
* Modified test to check attributes via setters

Results:
phpunit Zend/Form/View/Helper/FormElementErrorsTest.php
OK (14 tests, 14 assertions)

phpunit Zend/Form/View/Helper/
OK (430 tests, 566 assertions)