Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [SF2][SF][SYMFONY2] Problem z method, jak zmienić?, niedziałający formularz
destyl
post
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 1.03.2015

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


Witam, tak jak w temacie, mam problem z formularzem.

Zdefiniowałem wszystkie typy pól, ładnie juz sie wyświetla z bootstrape, ale gdy chce zobaczyć czy faktycznie zapisuje dane z formularza, to po kliknięciu buttona, strona sie odświeża i w pasku adresu przekazane są dane z formularza.. Doszedłem do wniosku ze musi być problem z metodą, ale nie wiem jak ją zmienić..

tutaj controler:
  1. public function registerAction(Request $Request){
  2.  
  3. $form = $this ->createForm( new rejestracjaType());
  4.  
  5. $form->handleRequest($Request);
  6. if($Request->isMethod('POST')){
  7. if($form->isValid()){
  8.  
  9. $savePath = $this->get('kernel')->getRootDir().'/../web/uploads/';
  10. $testForm = $form->getData();
  11.  
  12. $randVal = rand(1000, 9999);
  13. $dataFileName = sprintf('data_%d.txt', randVal);
  14.  
  15. file_put_contents($savePath.$dataFileName, print_r($testForm, TRUE));
  16.  
  17. $testForm = 'Zapisano dane formularza!';
  18. }
  19. }else{
  20.  
  21. $testForm = 'NIMA';
  22. }
  23.  
  24. return array(
  25. 'form' =>$form->createView(),
  26. 'testForm' => isset($testForm) ? $testForm : NULL,
  27. );
  28. }


a Tutaj typ:
  1. public function buildForm(FormBuilderInterface $builder, array $options)
  2. {
  3. $builder
  4.  
  5. ->add('user', 'text', array(
  6. 'label' => 'Nazww użytkownika'))
  7. ->add('email', 'email' , array(
  8. 'label' => 'Email'))
  9. ->add('pass', 'password', array(
  10. 'label' => 'Hasło'))
  11. ->add('pass2', 'password', array(
  12. 'label' => 'Powtóż hasło'))
  13. ->add('save', 'submit', array(
  14. 'label' => 'Zarejsetruj!'
  15. ));
  16. }


Po uruchomieniu strony wyświetla sie nima, wiec to musi być coś z method.... Jakieś pomysły?

Ten post edytował destyl 1.03.2015, 17:24:35
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: 3.10.2025 - 05:10