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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:08:40+00:00 2026-06-02T04:08:40+00:00

I have index action, that print 1) form for creating new Entity; 2) list

  • 0

I have index action, that print 1) form for creating new Entity; 2) list of all Entities:

public function indexAction()
{
    $em = $this->getDoctrine()->getEntityManager();

    $entities = $em->getRepository('MyBundle:Entity')->findAll();

    return array(
        'entities' => $entities,
    );
}

Twig:

{% block content %}
    {% render "MyBundle:Entity:new" %}
    {% render "MyBundle:Entity:list" %}
{% endblock %}

newAction in Entity Controller is standart form controller:

public function newAction()
{
    $entity = new Entity();
    $form = $this->createForm(new EntityType(), $entity);

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

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getEntityManager();
            $em->persist($entity);
            $em->flush();

            // NOT WORK
            return $this->redirect($this->generateUrl('entity_show',
                array('id' => $entity->getId())));
        }
    }
    return array(
        'form' => $form->createView(),
    );
}

Redirect after entity persisting isn’t work, error:

An exception has been thrown during the rendering of a template
("Error when rendering "http://example.com/app_dev.php/url/"
(Status code is 302).") in MyBundle:Default:index.html.twig at line 2.
  • 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-02T04:08:41+00:00Added an answer on June 2, 2026 at 4:08 am

    Unfortunately, this is by design. You cannot redirect from embedded controllers. As a workaround, you can post to different URL, save referrer, do stuff you need in there and redirect back with results.

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

Sidebar

Related Questions

I have a post html form, and the action is index.php, which is the
I have the following index action: class ExpensesController < ApplicationController def index() @expenses =
I have a controller named Content, which has an Index action, which is associated
Having this route: map.foo 'foo/*path', :controller => 'foo', :action => 'index' I have the
How can I prevent caching on exception? I have this action: caches_page :index ...
Let's say we have index.php and it is stored in /home/user/public/www and index.php calls
I have a form that needs to run a php script once the submit
I have a form that is filled automatically by a JS My Form is:
Here is my dilemma. I have a collection of entities that I want to
I have a ASP.Net MVC form that upon submit I need a couple of

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.