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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:49:25+00:00 2026-06-11T18:49:25+00:00

I am a newbie to zend framework. I am developing a simple user registration

  • 0

I am a newbie to zend framework. I am developing a simple user registration application in zend. I have both add and edit functionalities in my application. I can add a new user perfectly using my application. But when I try to edit user information other than password the validators used for password and passwordConfirmation fields gives errors. I need to remove/disable validators of password and passwordConfirmation fields only when I want to edit the user informations other than password.

My form:

$password = new Zend_Form_Element_Password('password');
        $password->setRequired(true)
        ->addFilter('StringTrim')
        ->addFilter('StripTags')
        ->addValidator('NotEmpty', false, array('messages'=>'password cannot be empty'))
        ->addValidator('StringLength', false, array(2, 20, 'messages'=>'password must be 2-20 character'))
        ->setLabel('Password:');
        $this->addElement($password);

        $confirmPassword = new Zend_Form_Element_Password('confirmPassword');
        $confirmPassword->setRequired(true)
        ->addFilter('StringTrim')
        ->addFilter('StripTags')
        ->addValidator('NotEmpty', false, array('messages'=>'password do not match'))
        ->addValidator(new Application_Validate_PasswordConfirmation())
        ->setLabel('Retype password');

My validator class:

class Application_Validate_PasswordConfirmation extends Zend_Validate_Abstract
{
     const NOT_MATCH = 'notMatch';

     protected $_messageTemplates = array(
     self::NOT_MATCH => 'Password confirmation does not match'
     );

     public function isValid($value, $context = null)
     {
         $value = (string) $value;
         $this->_setValue($value);

         if (is_array($context)) {
            if (isset($context['password']) && ($value == $context['password']))
            {
                return true;
            }
         } elseif (is_string($context) && ($value == $context)) {
                return true;
           }

         $this->_error(self::NOT_MATCH);
         return false;
     }
}
  • 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-06-11T18:49:26+00:00Added an answer on June 11, 2026 at 6:49 pm
        $modelUsers = new Model_Users();
        $userId = $this->_getParam('userId');
    
        if ($userId) {
            $populateData = array();
    
            $user = $modelUsers->fetch($userId);
    
            if ($user instanceof Model_User) {
                $populateData = $user->toArray();
            }
            $form = $this->_getAddForm($user->email, $user->username, $user->phone);
            $password = $this->getRequest()->getPost('password');
            if (trim($password) == '') {
                $form->getElement('password')
                ->setRequired(false)
                ->clearValidators();
    
                $form->getElement('confirmPassword')
                ->setRequired(false)
                ->clearValidators();
            }
    
        }
       else {
            $form = $this->_getAddForm($mail=null, $username=null, $phone=null);
       }
        $request = $this->getRequest();
    
        if ($request->isPost()) {
    
            $post = $request->getPost();
            if ($form->isValid($post)) {
                $values = $form->getValidValues($post);
    

    This is how I solve this problem definitely with the help of @drew010

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

Sidebar

Related Questions

As a newbie of Zend framework, I have a few version-dependent questions on the
I am newbie in zend framework , a simple question : in my IndexController
I am newbie in Zend framework.And i have made sample project in netbeans.And it
I am a newbie with zend-framework and I am building a small application.. Everything
I am new bie with Zend framework. One of my application carries dynamic Drop
A total newbie question I know. I'm sing Zend framework, and sending an array
I am a newbie of Zend Framework. I downloaded the Zend Framework and then
I am a newbie to the Zend Framework. I just finished installing Zend Server
First of all I am a newbie. I installed zend framework in my wamp
I am using zend Framework Form, I am newbie in zend Framework and i

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.