Symfony 2 route error when adding parameters

7331

New Member
I seem to have come across an issue with Symfony 2 that I have not seen before (or more likley im missing something really obvious). I had a route which took no parameters and worked perfectly, linking up to the controller and displaying the correct view. I then updated the route to take a single parameter like so: \[code\]# Note routing gibbo_dummy_notes_Add: pattern: /notes/add/{notebook} defaults: { _controller: GibboDummyBundle:Note:add, notebook: 0} requirements: _method: POST|GET\[/code\]However if I now try and access this route \[code\]notes/add/test\[/code\] I get the error \[code\]The controller must return a response (null given). Did you forget to add a return statement somewhere in your controller?\[/code\]. If I remove the parameter it works perfectly \[code\]notes/add\[/code\].This setup is exactly the same as the rest of the routes that use parameters in my app. The action in the controller definitely returns a response object. If I place a \[code\]die('test');\[/code\] at the top of the action and remove the parameter from the URL I reach the die statement and see 'test', but if I add the parameter to the URL it shows the error, so its clearly not reaching my controller or action when including the parameter but as far as I can tell the route is setup correctly, and im not getting the normal route not defined error I would expect to see if there was an issue with the url.Im running it under the dev environment and I have tried other browsers / cleared cache etc. The action inside the controller NoteController looks like\[code\]public function addAction($notebook){ $pageTitle = 'Note'; $form = $this->createForm(new NoteType(), null, array( 'validation_groups' => array('add') )); $request = $this->getRequest(); if ($request->isMethod('POST')) { $form->bind($request); if ($form->isValid()) { /** @var $em \Doctrine\ORM\EntityManager */ $em = $this->getDoctrine()->getManager(); /** @var $note Note */ $note = $form->getData(); $note->setNotebook(); $em->persist($note); $em->flush(); return $this->redirect($this->generateUrl('gibbo_dummy_note_View')); } } return $this->render('GibboDummyBundle:Note:new.html.twig', array( 'pageTitle' => $pageTitle, 'form_add' => $form->createView(), 'selected' => 'codebooks' ));}\[/code\]Can anyone shed some light about what I might be doing wrong?
 
Back
Top