1

I am using JavaScript tabs to render different layouts corresponding to different views with different forms.

I have a main route as follows :

/**
 * @Route("/my_ingredients", name="my_ingredients")
 * @Method("GET")
 * @Template("MarketPlace/UserIngredient/my_ingredients.html.twig")
 */
public function myIngredientsAction()
{
    return array();
}

In the myingredients layout I have the following :

        {% if ingredient_form is defined %}
            {% include 'MarketPlace/Product/create_ingredient.html.twig' %}
        {% else %}
            {{ render(controller('AppBundle:MarketPlace/Product:createIngredient')) }}
        {% endif %}

In the createIngredient action I have :

/**
 * @Route("/create_ingredient", name="create_ingredient")
 * @Method({"POST", "GET"})
 * @Template("MarketPlace/Product/create_ingredient.html.twig")
 * @param Request $request
 * @return array|\Symfony\Component\HttpFoundation\RedirectResponse
 */
public function createIngredientAction(Request $request)
{

    $productManager = $this->get('product_manager');
    $ingredient = new Product();
    $ingredientForm = $productManager->getIngredientCreateForm($ingredient);

    $formManager = $this->get('form_manager');

    if ($request->getMethod()=='POST')
    {
        if ($formManager->handleRequestAndValidatePersist($ingredientForm,$ingredient))
        {
            $productManager->saveUserIngredientOnCreateIngredient($ingredient);
            return $this->redirect($this->generateUrl('my_ingredients')."#choose");
        }
    }

    return $this->render(
        "MarketPlace/Product/create_ingredient.html.twig",
        array(
            'ingredient_form' => $ingredientForm->createView()
        )
    );
}

Finally in the create_ingredient layout I I have only :

{{ form(ingredient_form) }}
{{ form_stylesheet(ingredient_form) }}
{{ form_javascript(ingredient_form) }}

Why is this generating an infinite loop ? I am under the impression I am correctly calling GET->myIngredientsAction->GET=>{{ render(controller('AppBundle:MarketPlace/Product:createIngredient')) }}->GET=>render("MarketPlace/Product/create_ingredient.html.twig")...

Any help would be very appreciated!

laser
  • 1,388
  • 13
  • 14
Sébastien
  • 5,263
  • 11
  • 55
  • 116

1 Answers1

1

This error only occurs when xdebug is installed and is common with the default maximum of 100 (without xdebug, there is no cap).

 xdebug.max_nesting_level = 300

in your php.ini will fix it up

Matteo
  • 37,680
  • 11
  • 100
  • 115