Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [SF][SF2][Symfony2]Request data
gentleman
post
Post #1





Grupa: Zarejestrowani
Postów: 41
Pomógł: 1
Dołączył: 17.05.2013

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


witam,
  1. public function addAction(Request $request) {
  2.  
  3. $user = new Users();
  4. $form = $this->createFormBuilder($user)
  5. ->add('name', 'text')
  6. ->add('username', 'text')
  7. ->getForm();
  8.  
  9. $form->bindRequest($request);
  10.  
  11. if ($request->getMethod() == 'POST') {
  12.  
  13. $em = $this->getDoctrine()->getEntityManager();
  14. $em->persist($form->getData());
  15. $em->flush();
  16.  
  17. echo 'ok';
  18.  
  19. } else {
  20.  
  21. echo 'error';
  22.  
  23. }
  24.  
  25. }

dlaczego wyświetla mi się formularz z napisem error ?, na pewno metoda formularza jest post.

oraz chce wyświetlić np samo imię i żaden z tych niżej nie działa.
  1. $this->get('request')->request->get('name');
  2. $request->request->get('name');


coś źle robie? proszę o wskazówki i porady biggrin.gif

oczywiście mam dołączone
  1. use Symfony\Component\HttpFoundation\Request;


Ten post edytował gentleman 31.05.2013, 15:08:06
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: 20.08.2025 - 12:38