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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:32:05+00:00 2026-06-01T04:32:05+00:00

I have a template for editing a franchise. Inside that template I have two

  • 0

I have a template for editing a franchise. Inside that template I have two things: an embedded controller who show me a summary table with all the franchise already stored in the database, with an “edit” button for each row, and the form filled with the data of the franchise I’m currently editing.

The problem is that when I process the form and the validation fails, the summary table created by the embedded controller, shows me the franchise I was trying to modify with the values that I entered in the form, even though it didn’t pass the validation and the database was never updated.

The code has some spanish words so, just for clarification, “franquicia” means “franchise”

The method for rendering and validating the form is:

public function editarAction($superusuario_id, $franquicia_id)
{
    $request = $this->getRequest();

    $em = $this->getDoctrine()->getEntityManager();
    $franquicia = $em->getRepository('FacturaBundle:Franquicia')->findOneById($franquicia_id);

    $form = $this->createForm(new FranquiciaType(), $franquicia);

    if($request->getMethod() == 'POST') 
    {
        $form->bindRequest($request);
        if($form->isValid()) 
        {
            $em = $this->getDoctrine()->getEntityManager();
            $em->persist($franquicia);
            $em->flush();
            return $this->redirect($this->generateUrl('s_listar_franquicias', array('superusuario_id'=>$superusuario_id)));
        }
    }

    return $this->render('FacturaBundle:Superusuario:franquicia-editar.html.twig', 
                   array('superusuario_id'=>$superusuario_id, 
                         'franquicia_id'=>$franquicia_id, 
                         'form'=>$form->createView(),  
                         'franquicia'=>$franquicia ));
}

The method used by the embedded controller is:

public function listarTodasAction($superusuario_id)
{
    $em = $this->getDoctrine()->getEntityManager();
    $franquicias = $em->getRepository('FacturaBundle:Franquicia')->findAll();

    return $this->render('FacturaBundle:Superusuario:franquicia-listar-todas.html.twig', array('superusuario_id'=>$superusuario_id, 'franquicias'=>$franquicias));
}

I’m not pasting the code for the templates because it’s too long but I will do it if needed.

Can anyone help me?

  • 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-01T04:32:07+00:00Added an answer on June 1, 2026 at 4:32 am

    The basic problem is that $form->bindRequest actually updates $franquicia with posted information. D2 caches everything so the changes show up later on. Use refresh to set it back to it’s original data:

        if($form->isValid()) 
        {
            ...
        }
        $this->getDoctrine()->getEntityManager()->refresh($franquicia);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have template that looks like this: 100 template<size_t A0, size_t A1, size_t A2,
I have a template set up that I'm making ajax calls to via jQuery.
i have this template field inside a gridview. <asp:TemplateField ItemStyle-HorizontalAlign=Center> <ItemTemplate> <asp:ImageButton ID=ImageButton2 ImageUrl=~/images/DeleteRecord.gif
I have a custom editor template for a vehicle part that is used in
I have a question regarding editing/saving data in database using Django. I have template
I have the default SiteEdit Inline Editing Template Building Blocks in my compound component
I have a recursive template definition (I just made up that term). I think
I have placed a textblock in a slider thumb by Template editing. I want
I'm using an AutoCompleteBox from the WPF Toolkit inside a DataGridTemplateColumn's editing template in
I have some flatpages with empty content field and their content inside the template

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.