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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:43:31+00:00 2026-06-12T12:43:31+00:00

I have split up the user’s account area into different forms, then for the

  • 0

I have split up the user’s account area into different forms, then for the registration form I am pulling these bits together like so:

class RegistrationFormType extends AbstractType
{

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('email', 'email', array(
            'label' => '* Email address:'
        ))
        ->add('account_personal', 'my_personalinfo_form', array(
            'property_path' => 'account'
        ))
        ->add('account_contact', 'my_contactinfo_form', array(
            'property_path' => 'account'
        ))
    ;
}

The problem is that error messages for account_personal are bubbling to the top of the form. For example “Please enter your first name” if first name is left blank in the personal info form. The ‘personal’ and ‘contact’ forms work fine in their own forms on their own pages.

The error messages for account_contact are fine and appear next to the correct fields.

HOWEVER, if I swap the two ->add bits about above (so have account_contact first) then the problem reverses; the error messages for account_personal work now appear fine next to their corresponding fields, but now the errors for account_contact get bubbled to the top!

Any suggestions much appreciated!

—– EDIT —–

Personal info form:

class PersonalInfoType extends AbstractType
{

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('title', 'text')
        ->add('first_name', 'text', array(
            'required' => true,
            'label' => '* First name:'
        ))
        ->add('last_name', 'text', array(
            'required' => true,
            'label' => '* Surname:'
        ))
    ;
}

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
    $resolver->setDefaults(array(
        'data_class' => 'My\UserBundle\Entity\Account',
        'validation_groups' => array('personalInfo')
    ));
}

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

Contact info form:

class ContactInfoType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('postcode', 'text', array(
            'required' => true
        ))
        ->add('address_1', 'text', array(
            'required' => true
        ))
        ->add('address_2', 'text', array(
            'required' => false
        ))
        ->add('address_3', 'text', array(
            'required' => false
        ))
        ->add('town', 'text')
        ->add('phone_daytime', 'text', array(
            'required' => true
        ))
        ->add('phone_mobile', 'text', array(
            'required' => true
        ))
    ;
}

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
    $resolver->setDefaults(array(
        'data_class' => 'My\UserBundle\Entity\Account',
        'validation_groups' => array('contactInfo')
    ));
}

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

and the Account entity for completion:

/**
 * My\UserBundle\Entity\Account
 *
 * @ORM\Entity
 * @ORM\Table(
 *      name="accounts"
 * )
 */
class Account
{
/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;

/**
 * @ORM\Column(type="string", length=25, nullable=true)
 * @Assert\Choice(choices = {"Mr", "Mrs", "Miss", "Ms", "Dr", "Prof"}, message = "Choose a valid title", groups={"personalInfo"})
 */
protected $title;

/**
 * @ORM\Column(type="string", length=150, nullable=true)
 * @Assert\NotBlank(message="Please enter your first name", groups={"personalInfo"})
 * @Assert\Length(max=150, maxMessage="null|Your first name must have less than {{ limit }} characters", groups={"personalInfo"})
 * @Assert\Regex(
 *     pattern="/\d/",
 *     match=false,
 *     message="Your name cannot contain a number"
 * )
 */
protected $first_name;

/**
 * @ORM\Column(type="string", length=150, nullable=true)
 * @Assert\NotBlank(message="Please enter your last name", groups={"personalInfo"})
 * @Assert\Length(max=150, maxMessage="null|Your last name must have less than {{ limit }} characters", groups={"personalInfo"})
 * @Assert\Regex(
 *     pattern="/\d/",
 *     match=false,
 *     message="Your name cannot contain a number"
 * )
 */
protected $last_name;

/**
 * @ORM\Column(type="string", length=255, nullable=true)
 * @MyAssert\Phone(message="Your daytime phone number is not valid", groups={"contactInfo"})
 */
protected $phone_daytime;

/**
 * @ORM\Column(type="string", length=255, nullable=true)
 * @MyAssert\MobilePhone(message="Your mobile phone number is not valid", groups={"contactInfo"})
 */
protected $phone_mobile;

/**
 * @ORM\Column(type="string", length=255)
 * @Assert\NotBlank(message="Please enter the first line of your address", groups={"contactInfo"}
 * @Assert\Length(max=250, maxMessage="null|The first line of your address must have less than {{ limit }} characters", groups={"contactInfo"})
 */
protected $address_1;

/**
 * @ORM\Column(type="string", length=255, nullable=true)
 * @Assert\Length(max=250, maxMessage="null|The second line of your address must have less than {{ limit }} characters", groups={"contactInfo"})
 */
protected $address_2;

/**
 * @ORM\Column(type="string", length=255, nullable=true)
 * @Assert\Length(max=250, maxMessage="null|The third line of your address must have less than {{ limit }} characters", groups={"contactInfo"})
 */
protected $address_3;

/**
 * @ORM\Column(type="string", length=45, nullable=true)
 * @Assert\NotBlank(message="Please enter your town", groups={"contactInfo"})
 * @Assert\Length(max=45, maxMessage="null|Your town name must have less than {{ limit }} characters", groups={"contactInfo"})
 */
protected $town;

/**
 * @ORM\Column(type="string", length=45, nullable=true)
 * @Assert\NotBlank(message="Please enter your postcode", groups={"contactInfo"})
 * @MyAssert\Postcode(message="Invalid postcode entered", groups={"contactInfo"})
 */
protected $postcode;

 ... etc
  • 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-12T12:43:32+00:00Added an answer on June 12, 2026 at 12:43 pm

    The issue is down to using the same property path twice in one form. I raised an issue here:

    https://github.com/symfony/symfony/issues/5578

    On which I posted this solution:

    I came up with a different tact of creating a new FormType to contain the 2 embedded forms using virtual fields:

    class RegistrationAccountFormType extends AbstractType
    {
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('account_personal', 'my_personalinfo_form', array(
                'data_class' => 'My\UserBundle\Entity\Account',
                'virtual' => true
            ))
            ->add('account_contact', 'my_contactinfo_form', array(
                'data_class' => 'My\UserBundle\Entity\Account',
                'virtual' => true
            ))
        ;
    }
    
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'My\UserBundle\Entity\Account'
        ));
    }
    
    public function getName()
    {
        return 'my_registration_account_form';
    }
    }
    

    and then replaced these fields in the main RegistrationFormType with

    ->add('account', new RegistrationAccountFormType)
    

    This seems like the ‘proper’ way of doing this, it keeps the property_paths unique within the form and no property_path changes required in the sub-forms either.

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

Sidebar

Related Questions

I have a windows forms app where I have split different functionality into several
Hi I have a long form that is split into a wizard. To prevent
I want to have user rights split into two. Some of the policies at
I have to split a user name into first name and last name, but
I have a split container in the left panel is a user control with
Say I have I split-window with C-x 2 or C-x 3 and then I
I have a form split apart throughout 4 tabs. One of the tabs contains
i have this: Dim split As String() = temp_string.Split(,) ''#feed all info into global
I have a Javascript For Loop... var CookieName = Tab,EduTab,EduTab,user; var tString = CookieName.split(',');
I currently have the following code: string user = @DOMAIN\USER; string[] parts = user.Split(new

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.