Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Symfony][Symfony2]"errors" does not exist, Przesyłanie do szablonu listy błędów.
q3trm
post
Post #1





Grupa: Zarejestrowani
Postów: 83
Pomógł: 1
Dołączył: 26.02.2013

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


Nie mogę dojść gdzie popełniam błąd dry.gif , to mój pierwszy formularz w Symfony przykład z cookbook.


  1. public function contactAction()
  2. {
  3. $enquiry = new Enquiry();
  4.  
  5. $form = $this->createForm(new EnquiryType(), $enquiry);
  6.  
  7. $request= $this ->getRequest();
  8.  
  9. if ($request == 'POST') {
  10. $form ->bind($request);
  11.  
  12. $validator = $this->get('validator');
  13. $errors = $validator->validate($enquiry);
  14.  
  15. if ($form ->isValid()) {
  16.  
  17. if (count($errors) > 0) {
  18. return $this ->render('MultimediaBlogBundle:Default:contact.html.twig', array(
  19. 'errors' => $errors ));
  20. }
  21. }
  22. return $this -> redirect($this->generateUrl('multimedia_contact'));
  23. }
  24. return $this ->render('MultimediaBlogBundle:Default:contact.html.twig', array(
  25. 'form' => $form->createView()));
  26. }
  27.  
  28.  


  1. <ul>
  2. {% for error in errors %}
  3. <li>{{ error.message }}</li>
  4. {% endfor %}
  5. </ul>


Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 21.08.2025 - 17:02