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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:56:48+00:00 2026-06-07T04:56:48+00:00

I’m trying to override SonataUserBundle’s ProfileFormType. I have added some extra fields to that

  • 0

I’m trying to override SonataUserBundle’s ProfileFormType.
I have added some extra fields to that form and all the fields render on the page. So that works. But now I’m wondering why the user’s data doesn’t load, as the firstname, lastname, … is already known but just not shown in the textboxes of the form.

The overridden ProfileController class’s editProfileAction:

/**
 * @return Response
 *
 * @throws AccessDeniedException
 */
public function editProfileAction()
{
    $user = $this->container->get('security.context')->getToken()->getUser();
    if (!is_object($user) || !$user instanceof UserInterface) {
        throw new AccessDeniedException('This user does not have access to this section.');
    }

    $form = $this->container->get('sonata.user.profile.form');
    $formHandler = $this->container->get('sonata.user.profile.form.handler');

    $process = $formHandler->process($user);
    if ($process) {
        $this->setFlash('fos_user_success', 'profile.flash.updated');

        return new RedirectResponse($this->generateUrl('sonata_user_profile_show'));
    }

    // This doesn't show the firstname
    die($form->getData()->getFirstname());

    return $this->render('SonataUserBundle:Profile:edit_profile.html.twig', array(
        'form' => $form->createView(),
        'theme' => $this->container->getParameter('fos_user.template.theme')
    ));
} 

The overridden ProfileFormHandler class’s process function:

public function process(UserInterface $user)
{
    $this->form->setData($user);

    // This DOES show the firstname 
    die($this->form->getData()->getFirstname());

    if ('POST' == $this->request->getMethod()) {
        $this->form->bindRequest($this->request);

        if ($this->form->isValid()) {
            $user->upload();
            $this->onSuccess($user);

            return true;
        }

        // Reloads the user to reset its username. This is needed when the
        // username or password have been changed to avoid issues with the
        // security layer.
        $this->userManager->reloadUser($user);
    }

    return false;
}

Services.yml:

services:
    application_sonata_user.registration.form.type:
        class: Application\Sonata\UserBundle\Form\Type\RegistrationFormType
        arguments: [%fos_user.model.user.class%]
        tags:
            - { name: form.type, alias: application_sonata_user_registration }

    application_sonata_user.profile.form.type:
        class: Application\Sonata\UserBundle\Form\Type\ProfileType
        arguments: [%fos_user.model.user.class%]
        tags:
            - { name: form.type, alias: application_sonata_user_profile }

    application_sonata_user.search.form.type:
        class: Application\Sonata\UserBundle\Form\Type\SearchFormType
        arguments: [%fos_user.model.user.class%]
        tags:
            - { name: form.type, alias: application_sonata_user_search }

    application_sonata_user.form.handler.profile:
        class: Application\Sonata\UserBundle\Form\Handler\ProfileFormHandler
        arguments: ["@fos_user.profile.form", "@request", "@fos_user.user_manager", "@ewz_search.lucene"]
        scope: request
        public: 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-07T04:56:51+00:00Added an answer on June 7, 2026 at 4:56 am

    In the services.yml file, I had to put:

    arguments: ["@sonata.user.profile.form", "@request", "@fos_user.user_manager", "@ewz_search.lucene"] 
    

    instead of

    arguments: ["@fos_user.profile.form", "@request", "@fos_user.user_manager", "@ewz_search.lucene"]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put

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.