ZF-2988: Add public accessors for errors and messages for elements

Issue Type: Improvement Created: 2008-03-28T08:37:13.000+0000 Last Updated: 2008-09-02T10:39:22.000+0000 Status: Resolved Fix version(s): - 1.6.0 (02/Sep/08)

Reporter: Amr Mostafa (alienbrain) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Form

Related issues: Attachments:


I didn't want to add a custom validators and decided to override my form's isValid() instead. Doing my custom logic there was straightforward, except that I couldn't set the errors on my elements as they are managed internally by Zend_Form_Element with no public accessors.

I propose that we add public accessors for errors and messages. It makes sense regardless of the use case I demonstrated.


Posted by Andries Seutens (andries) on 2008-03-31T15:22:50.000+0000

Currently, you always have to write your own validator, in order to get an error in the stack. I also think it'd be usefull to have a method to push your own custom errors into the error stack on a per element basis:

<pre class="highlight">
$myElement->addError('key', 'error message');

It would also be convenient to be able to do this on form level, where the input would be an array:

<pre class="highlight">
$form->addErrors(Array $myCustomErrors);

vote +1

Posted by Wil Sinclair (wil) on 2008-03-31T16:04:35.000+0000

Please evaluate and categorize as necessary.

Posted by Steven Reed (stevereed) on 2008-05-22T03:46:26.000+0000

Can this please include hasErrors()?

An example use case would be determining whether or not to add an 'error' class to a tag when using the ViewScript decorator:

<pre class="highlight">

    // label/element output here

Posted by Matthew Weier O'Phinney (matthew) on 2008-07-17T14:19:07.000+0000

New functionality complete as of r10162.

Posted by Wil Sinclair (wil) on 2008-09-02T10:39:22.000+0000

Updating for the 1.6.0 release.

Have you found an issue?

See the Overview section for more details.


© 2006-2020 by Zend by Perforce. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.