Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [SF2][Symfony][Symfony2]Attempted to call method "redirectToRoute"
kosmos
post
Post #1





Grupa: Zarejestrowani
Postów: 367
Pomógł: 17
Dołączył: 4.03.2008

Ostrzeżenie: (0%)
-----


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?
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 26.09.2025 - 19:12