Passing route url format to symfony2 form with get method

后端 未结 3 525
一生所求
一生所求 2021-01-23 10:36

Not sure if I properly wrote the subject but anyway.

Since you can create specific routes with different parameters for eg:

_search:
    pattern: /page/{         


        
3条回答
  •  面向向阳花
    2021-01-23 11:03

    I've too encountered this issue and I managed to resolve it with a slightly different solution.

    You could also reroute like @Thomas Potaire suggested, but in the same controller, beginning your controller with :

    /**
     * @Route("/myroute/{myVar}", name="my_route")
     */
    public function myAction(Request $request, $myVar = null)
    {
        if ($request->query->get('myVar') !== null) {
            return $this->redirectToRoute('my_route', array(
                'myVar' => str_replace(' ','+',$request->query->get('myVar')) // I needed this modification here
            ));
        }
        // your code...
    }
    

提交回复
热议问题