Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [SF2][Symfony][Symfony2]Attempted to call method "redirectToRoute"
Forum PHP.pl > Forum > PHP > Frameworki
kosmos
Witam
Mam problem z przekierowaniem do innej strony:

  1. namespace Acme\PageBundle\Controller;
  2.  
  3. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  4. use Acme\PageBundle\Entity\Message;
  5. use Symfony\Component\HttpFoundation\Request;
  6. class DefaultController extends Controller
  7. {
  8. public function contactAction(Request $request)
  9. {
  10. $message = new Message();
  11. $message->setName('');
  12. $message->setSurname('');
  13.  
  14. $form = $this->createFormBuilder($message)
  15. ->add('name','text')
  16. ->add('Wyślij zapytanie','submit')
  17. ->getForm();
  18.  
  19. $form->handleRequest($request);
  20.  
  21. if ($form->isValid()) {
  22. // perform some action...
  23. return $this->redirectToRoute('acme_task_success');
  24. }
  25.  
  26. return $this->render('AcmePageBundle:Default:contact.html.php', array(
  27. 'form' => $form->createView(),
  28. ));
  29. }
  30. }


Po wywołaniu submita pojawia się problem z wywołaniem funkcji redirectToRoute nie wiem dlaczego

Attempted to call method "redirectToRoute" on class "Acme\PageBundle\Controller\DefaultController" in C:\xampp\htdocs\symfony\src\Acme\PageBundle\Controller\DefaultController.php line 84.


EMERGENCY - Call to undefined method Acme\PageBundle\Controller\DefaultController::redirectToRoute()
CRITICAL - Uncaught PHP Exception Symfony\Component\Debug\Exception\UndefinedMethodException: "Attempted to call method "redirectToRoute" on class "Acme\PageBundle\Controller\DefaultController" in C:\xampp\htdocs\symfony\src\Acme\PageBundle\Controller\DefaultController.php line 84." at C:\xampp\htdocs\symfony\src\Acme\PageBundle\Controller\DefaultController.php line 84


Pomożecie?
ohm
Jaka wersja symfony?

Cytat
The redirectToRoute() method was added in Symfony 2.6. Previously (and still now), you could use redirect() and generateUrl() together for this (see the example above).
kosmos
"symfony/symfony": "2.5.*",

dzięki za info
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.