Note that there are some explanatory texts on larger screens.

plurals
  1. POIn a Zend_Form, how to avoid Zend_Validate_Email from generating multiple errors?
    primarykey
    data
    text
    <p>I am building a ZendFramework application which as a login form asking for an email address and password - it seemed to make sense to validate the email address before hitting the database with the login attempt, as an invalid email would never lead to a valid hit. Zend_Validate_EmailAddress seemed like the right way to go, but I am having an issue with it generating multiple errors (question at the bottom, after the code).</p> <p>My form currently has the following</p> <pre><code>//WPMail_Form_Login::init() $email = $this-&gt;addElement('text', 'email', array( 'label'=&gt;'Email', 'required'=&gt;true, 'filters'=&gt;array('stringtrim'), 'validators'=&gt;array(array('emailaddress', true, array( 'messages'=&gt;array( 'emailAddressInvalidHostname'=&gt;'Your email address is invalid', 'emailAddressInvalidFormat'=&gt;'Your email address is invalid', '...'=&gt;'(repeat for all message templates)' ) ))), )); </code></pre> <p>In the controller I directly pass the form into the view:</p> <pre><code>// WPMail_AuthController::loginAction() $this-&gt;view-&gt;form = $form; </code></pre> <p>And in the view, it's directly echo'd:</p> <pre><code>// views/scripts/auth/login.phtml &lt;?php echo $this-&gt;form ?&gt; </code></pre> <p>The result is currently something like this:</p> <pre><code>- Your email address is invalid - 'asda!!!' does not match the expected structure for a DNS hostname - 'asda!!!' does not appear to be a valid local network name </code></pre> <p>What I want want to know is: Is it possible to configure Zend<code>_</code>Validate<code>_</code>EmailAddress in such a way that it only produces a single email-invalid error? By 'configure' I mean, without extending the class and overriding the logic with my own.</p> <p>TIA.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload