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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:53:07+00:00 2026-05-28T04:53:07+00:00

I have a form for changing passwords, it checks the password field for min_length

  • 0

I have a form for changing passwords, it checks the password field for min_length and required. Then it compares the password field with the confirm field.

If I post to this form with less than the minimum required characters (and the password and confirm box match), it throws errors for min length (which is expected) and for password mismatch (unexpected).

Can anyone tell why?

<?php

class ChangeMyPasswordForm extends sfForm {

    const PASSWORD_MIN_LENGTH_MSG = "<li>We could not update your password because your password must be at least 8 characters long. Please choose a different password.</li>";
    const PASSWORD_MISMATCH_MSG   = "<li>We could not update your password because your passwords didn't match. Please try again.</li>";
    const PASSWORD_REQUIRED_MSG   = "<li>We could not update your password because your password was blank. Please enter a password.</li>";

    protected static $labels = array(
        'password' => 'Your Password',
        'confirm'  => 'Re-enter Password',
    );

    /**
     * Called in sfForm's constructor. 
     */
    public function configure()
    {   
        $this->setWidgets(array(
           'password'  => new sfWidgetFormInputPassword(array()),
             'confirm' => new sfWidgetFormInputPassword(array()),
        ));

        $this->setValidators(array(
            'password' => $this->_setPasswordValidator(),
                 'confirm' => new sfValidatorPass(),
        ));

        $this->mergePostValidator(
            new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 
                'confirm', array(), array(
                    'invalid' => self::PASSWORD_MISMATCH_MSG,
                )
            )
        );

        $this->widgetSchema->setLabels(self::$labels);
    }

    /**
     * Returns validators for the password field. 
     * @return sfValidatorString 
     */
    private function _setPasswordValidator()
    {
        $v = new sfValidatorString();
        $v->setOption('min_length', 8);
        $v->setMessage('min_length', self::PASSWORD_MIN_LENGTH_MSG);
        $v->setMessage('required', self::PASSWORD_REQUIRED_MSG);

        return $v;
    }
}

edit: this may help => the view where I’m throwing errors

<?php if ($form->hasGlobalErrors() || $form->hasErrors()): ?>
<div class="error">
  <p class="bottom"><b>Oops!</b></p>
  <ul>
    <?php foreach ($form->getGlobalErrors() as $name => $error): ?>
        <?php echo $error ?>
    <?php endforeach; ?>

        <?php foreach ($form->getErrorSchema()->getErrors() as $error): ?>
      <?php echo $error; ?>
    <?php endforeach; ?>
  </ul>
</div>
<? endif; ?>
  • 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-28T04:53:08+00:00Added an answer on May 28, 2026 at 4:53 am

    Finally figured it out. It looks like sfValidatorSchemaCompare compares the entire widget, validators and all (not just the values that they return). So If I’m comparing two widgets, and they dont have the same validators (i.e. one min_length = 3 and the other’s min_length = 6), it will fail.

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

Sidebar

Related Questions

I have a URL handler for changing passwords, such as this: url(r'^password/change/$', auth_views.password_change, {'template_name'
I have this form in HTML: <form action=# method=post> <label for=label-id>id</label> <input type=text name=id
I have form with such field: categories = forms.ModelChoiceField( queryset=Field.objects.all(), widget=CheckboxSelectMultiple, required=False ) And
I have form where user submits field. Field can have letters, numbers, and punctuation.
I have form in my page, I am using ajax.beginform(). Inside this form I
i have a web form who send post variables like: <form action=teacher.php method=post> <input
I have a form that uses the POST method to send data. The POST
I have a form like this: <form name=mine> <input type=text name=one> <input type=text name=two>
I don't have so much idea about changing the password using AdminPasswordChangeForm . I
I have a form field in a view that is separate from my initial

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.