Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3301472
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:45:16+00:00 2026-05-17T20:45:16+00:00

I used to have this form element to validate an email and display an

  • 0

I used to have this form element to validate an email and display an error message if the format was invalid:

  $email_users = new Zend_Form_Element_Text('email_users');
  $email_users->setLabel('Email:')
                      ->setRequired(false)
                      ->addFilter('StripTags')
                      ->addFilter('StringTrim')
                      ->addValidator('EmailAddress')
                      ->setErrorMessages(array('messages' => 'Invalid Email'));

setErrorMessages worked fine because this was the only validation I needed so it replaced all error messages with my custom one, now I had to add another validation to see if it already existed in my DB:

  $email_users = new Zend_Form_Element_Text('email_users');
  $email_users->setLabel('Email:')
                      ->setRequired(false)
                      ->addFilter('StripTags')
                      ->addFilter('StringTrim')
                      ->addValidators(array(
                          array('EmailAddress', true,
                              array(
                                  'messages' =>
                                      array(Zend_Validate_EmailAddress::INVALID => 'Invalid Email')
                                  )
                          ),
                          array('Db_NoRecordExists', true,
                              array(
                                  'messages' =>
                                    array(Zend_Validate_Db_NoRecordExists::ERROR_RECORD_FOUND => 'Email already exists'),
                                  'table' => 'users',
                                  'field' => 'email_users')
                          )));

The functionality is fine, the problem is that when the email is invalid it now shows me the default zend validate messages, ut when it exists it does show me my custom message. Is there any way to archive the previous functionality this way? (Replacing all invalid email messages) I can’t uset setErrorMessages since this shows me ‘invalid email’ when the email alrady exists.

I tried using ‘messages’ => ‘Error’ but nothing happens (no errors but the default messages show), I tried:

$emailValidator = new Zend_Validate_EmailAddress();
$emailValidator->setMessages(‘Invalid email’);

And on my form element I added

$email_users->addValidator($emailValidator)

Nothing same results. The closest I have gotten is doing ‘messages’ => array(Zend_Validate_EmailAddress::INVALID_FORMAT => ‘Invalid email’) this shows the msg when I type something like ’email@’ or ’email’ but if I type ’email@host’ it shows me 3 erros regarding the hostname, dns and localnetwork, which they don’t show when I use setMessages(‘Error’) (just displays ‘Error’),

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:45:16+00:00Added an answer on May 17, 2026 at 8:45 pm

    I posted an answer which explains how all the different error message setting functions work here,

    Zend validators and error messages: addValidator and addErrorMessage

    In short, try this:

    'messages' => 'Email already exists'

    instead of using an array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my c# application i have this small form which is used to set
I have written a login form, in this I have used, form and method
I have used this code to store Object to a file: try{ FileOutputStream saveFile=new
I have this bit of code. It is used to update the form after
I have not really used JavaScript before but I am trying to validate form
I used to have this code working with my Tomcat server: HttpRequestBase targetRequest =
I used to have this kind of simple JSON data and I could successfully
I have used this code for extracting urls from web page.But in the line
I have used this effect before, everything is in order (As far as I
I have used this query to alter the table field: ALTER TABLE `recordstudent` CHANGE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.