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 7079875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:43:32+00:00 2026-05-28T06:43:32+00:00

I have form called LoginForm, which extends the RecipeForm which in turn extends Zend_Form.

  • 0

I have form called LoginForm, which extends the RecipeForm which in turn extends Zend_Form. The RecipeFrom only returns my decorators.

When the form is submitted, I get the following error, ‘Message: Method addValidator does not exist’.

class Recipe_Form_LoginForm extends Recipe_Form_RecipeForm {
    public function init()
    {
        parent::init();
        $this->setName('loginform')
             ->setAction('/login');


        //  Add Email Element
        $email = $this->addElement('text', 'email', array(
            'label' => 'Email Addresses',
            'required'=> true,
            'size'=>12,
            'filters'=>array('StringTrim'),
            'decorators' => $this->getElementDecorator('email'),

        ));
       $email->addValidator(new Recipe_Validate_EmailAddress(), true, array(
           'messages' => array(
               Recipe_Validate_EmailAddress::INVALID => 
               'Please enter email in correct format',
               Recipe_Validate_EmailAddress::EMAILISEMPTY =>
               'Please enter email address'
       )));
}

class Recipe_Validate_EmailAddress extends Zend_Validate_Abstract
{
    const INVALID           =   'notvalid';
    const EMAILISEMPTY      =   'isempty';

     protected $_messageTemplates = array(
             self::INVALID => "Email is in invalid format",
             self::EMAILISEMPTY => "You have to fill email field"
        );

    public function isValid($value){
        $response = parent::isValid($value);
        if(!$response){
            $this->_message = array(self::INVALID => "Please enter a valid email address");
        }
        return $response;
    }
}
?>
  • 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-28T06:43:32+00:00Added an answer on May 28, 2026 at 6:43 am

    When you call $this->addElement() from within a Zend_Form object, it returns the form object itself, rather than the element you just created.

    You can make one of the following changes:

    $this->addElement('text', 'email', ...);
    $email = $this->getElement('email');
    $email->addValidator(...);
    
    // or
    
    $email = new Zend_Form_Element_Text('email');
    $email->addValidator(...)
          ->setLabel(...)
          ->setRequired(...);
    $this->addElement($email);
    

    To set your error message, I think you should do this instead of setting $this->_message.

    $this->_error(self::INVALID);
    

    Since it looks like your class is only extending Zend’s email validator to override the message, you can override Zend’s messages like this and not need to extend the class. This is taken from a validator in one of my projects, so ignore the extra stuff and just pay attention to the messages for the EmailAddress validator.

    $this->addElement('text', 'email', array(
            'label' => 'Email Address:',
            'required' => false,
            'filters' => array('StringTrim', 'StringToLower'),
            'validators' => array(
                array('EmailAddress', true, array(
                    'messages' => array(
                        Zend_Validate_EmailAddress::INVALID_FORMAT =>
                        "'%value%' is not a valid email address. Example: you@yourdomain.com",
                        Zend_Validate_EmailAddress::INVALID_HOSTNAME =>
                        "'%hostname%' is not a valid hostname for email address '%value%'"
                    )
                )),
                array('Db_RecordExists', true, array(
                    'table' => 'accounts', 'field' => 'email',
                    'messages' => array(
                        Zend_Validate_Db_RecordExists::ERROR_NO_RECORD_FOUND =>
                        "No account with that email address was found"
                    )
                ))
            ),
            'decorators' => $this->elementDecorators
        ));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a base and derived class called Node which form elements of a
I have a jQuery .get call that hits a URL which returns true or
I have a form called Form1.cs, which calls a class which we will refer
I have a WinForm project that contains a form called MainUI. You can see
I have a php page called form.php. When you go to this page it
I have a form with a submit button. I have called a function on
I have got a textbox on a form with a method being called from
I have ListBox called lstProductGroups. On a simple Windows Form, a method called GetGroups
Assume we have a single Windows form with a button called SimpleButton1. The following
i am creating a login form in which i have to set a flash

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.