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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:10:10+00:00 2026-05-30T02:10:10+00:00

I have build a form class to generate a form that will allow a

  • 0

I have build a form class to generate a form that will allow a user to type in a new password twice in order to change it.

code:

<?php

namespace UserBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\CallbackValidator;

class PasswordType extends AbstractType
{
    public function buildForm(FormBuilder $builder, array $options)
    {
        $builder->add('password', null);
        $builder->add('confirmPassword', null, array('label' => 'Confirm Password', 'property_path' => false));
        $builder->addValidator(new CallbackValidator(function($form)
            {
                if($form['confirmPassword']->getData() != $form['password']->getData()) {
                    $form['confirmPassword']->addError(new FormError('Passwords must match.'));
                }
            }));
    }

    public function getDefaultOptions(array $options)
    {
        return array(
            'data_class' => 'UserBundle\Entity\User',
        );
    }

    public function getName()
    {
        return 'password';
    }
}

Now, this class works pretty well, BUT my issues is that when I set the first password field to type “password” I get this error:

Circular reference detected in the “password” type (defined in class “UserBundle\Form\Type\PasswordType”).

And I cannot leave it set to “null” as it will use a normal text input field, which is not ideal.

Any ideas folks?

  • 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-30T02:10:11+00:00Added an answer on May 30, 2026 at 2:10 am

    The issue seems to be from using “password” as the getName() value.

    Before:

    public function getName()
    {
        return 'password';
    }
    

    After:

    public function getName()
    {
        return 'changePassword'; // basically anything other than 'password'
    }
    

    I changed this to “pass” and now I can use “password” to set the type, i.e.

    $builder->add('password', 'password');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form build with zend using a viewscript. I thought that by
I have to build a registration form using asp.net mvc 3 jquery validate. That
Every time I have to build a form with a DateTime field I try
I need to build a form where I have 2 comboBoxes . Select country
i have bought a template that have built in contact form problem is that
I'm trying to have the action of a HTML form built when the user
I have a complex form for a model Schedule that belongs to a parent
I have the following form: class ModuleItemForm2(forms.ModelForm): class Meta: model = Module_item fields =
I am looking for a form class that: Is standalone/doesnt need a framework to
In my web app I have a dynamically generated form that I use to

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.