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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:47:52+00:00 2026-05-28T03:47:52+00:00

In symfony. . . my form looks like this <?php class ChangeMyPasswordForm extends sfForm

  • 0

In symfony. . . my form looks like this

<?php

class ChangeMyPasswordForm extends sfForm {

    const PASSWORD_REQUIRED_MSG = "We could not update your password. Your password can not be blank. Please enter at least one character for a password.";

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

    public function configure()
    {   
        $this->setWidgets(array(
           'password'  => new sfWidgetFormInputPassword(array()),
             'confirm' => new sfWidgetFormInputPassword(array()),
        ));

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

        $this->validatorSchema->setOption('allow_extra_fields', true); 

        $this->mergePostValidator(
            new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::IDENTICAL, 
                'confirm', array(), array(
                    'invalid'=>'Passwords do not match. Please try again.'
                )
            )
        );

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

in my controller

public function executeMyAccountPassword(sfRequest $request) {
      $this->form = new ChangeMyPasswordForm();
      $this->validated=$request->getParameter('validated');

      $this->form->bind(array(
              'password' => $request->getParameter('password'),
              'confirm'  => $request->getParameter('confirm'),
      ));

      if ($request->isMethod('post')) {

          if ($this->form->isValid()) {
              $this->validated = true;

              // get player object
              $player = $this->getUser()->getProfile();
              $player->setPassword($request->getParameter('password'));
          }
      }

I’m trying to add a validator so the password field cannot be blank. I tried modifying

$this->setValidators(array('password'=>new sfValidatorString('required'=>'Please enter a password')));

But all then the form threw an error even when data was not posted. can anyone show me a proper example of how to validate two matched password fields and ensure that fields are not left blank (after form submission). Thanks !!

  • 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-28T03:47:53+00:00Added an answer on May 28, 2026 at 3:47 am

    You have a second error. Move the binding a few lines down, under the if. Meaning you should do the binding with the posted values

    if ($request->isMethod('post')) 
    {
      $this->form->bind(array(
        'password' => $request->getParameter('password'),
        'confirm'  => $request->getParameter('confirm'),
      ));
    
      ... etc...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to render a symfony form this way: My problem concerns the radio
I'm using Symfony 1.2 in a standard Propel form class. public function configure() {
In my symfony application I would like to get form model object before calling
I use symfony 1.4.11. I have frontend and backend form. Frontend : <?php {
Is there a simple way to declare CSS classes for Symfony form labels? This
Possible Duplicate: Symfony - Form requested url not found I'm working on a symfony
I have in Symfony 1.4 form: $this->setWidget('title', new sfWidgetFormInputText()); $this->setWidget('photo', new sfWidgetFormInputFile()); if i
I build a form with entity type like this: $form = $this->createFormBuilder() ->add('users', 'entity',
I'm using symfony with doctrine and I make a registration form. Email field is
I'm using Symfony 1.4. I'm posting a form via Jquery ajax to an action

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.