Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [Symfony] formularz nie zapisuje się
Forum PHP.pl > Forum > PHP > Frameworki
janek9
Witam

Mam pewien problem, a mianowicie formularz staje na akcji create, albo update i nie wyświetla się żaden błąd. Natomiast walidacje przechodzi poprawnie bo sprawdzałem. Zachowuje się tak, jakbym nie przekazywał do metody processForm. Korzystam z routingu i odwołuje się do akcji poprzez @my_create, @my_update we widoku formularza. Co może być tego przyczyną ?
destroyerr
Co Ci mamy poradzić skoro nie mamy pojęcia jaki kod stworzyłeś.
janek9
sry juz podaje kod:

  1. public function executeCreate(sfWebRequest $request)
  2. {
  3. $this->forward404Unless($request->isMethod('post') && $request->hasParameter('party'));
  4.  
  5. $this->form = new TpPartyForm();
  6.  
  7. $this->processForm($request, $this->form);
  8.  
  9. $this->setTemplate('new');
  10. }
  11.  
  12. public function executeEdit(sfWebRequest $request)
  13. {
  14.  
  15. $tp_party = $this->getRoute()->getObject();
  16. $this->getResponse()->setTitle($this->getResponse()->getTitle().' - Edytuj imprezę');
  17.  
  18. if($this->getUser()->getGuardUser()->getId() == $tp_party->getOwner())
  19. {
  20. $this->form = new TpPartyForm($this->getRoute()->getObject());
  21. }
  22. elseif($this->getUser()->getGuardUser()->getId() !== $tp_party->getOwner())
  23. {
  24. return $this->forward404();
  25. }
  26.  
  27.  
  28. }
  29.  
  30. public function executeUpdate(sfWebRequest $request)
  31. {
  32. //$this->forward404Unless($request->isMethod('post'));
  33.  
  34. $tp_party = $this->getRoute()->getObject();
  35.  
  36. if($this->getUser()->getGuardUser()->getId() == $tp_party->getOwner())
  37. {
  38.  
  39. $this->form = new TpPartyForm($tp_party);
  40.  
  41. $this->processForm($request, $this->form);
  42. $this->setTemplate('Edit');
  43.  
  44. }
  45. elseif($this->getUser()->getGuardUser()->getId() !== $tp_party->getOwner())
  46. {
  47. return $this->forward404();
  48. }
  49.  
  50. $this->setTemplate('edit');
  51.  
  52. rotected function processForm(sfWebRequest $request, sfForm $form)
  53. {
  54. $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
  55. if ($form->isValid())
  56. {
  57.  
  58.  
  59. $tp_party = $form->save();
  60.  
  61.  
  62. $this->redirect('myaccount_party_organize_party');
  63.  
  64. }
  65.  
  66. }
  67. }


to jest routing:

  1. myaccount_party_create:
  2. url: /account-party/create
  3. class: sfPropelRoute
  4. options: { model: TpParty, type: object }
  5. param: { module: myaccount_party, action: Create }
  6.  
  7. myaccount_party_edit:
  8. url: /account-party/:token/edit
  9. class: sfPropelRoute
  10. options: { model: TpParty, type: object, column: token}
  11. param: { module: myaccount_party, action: Edit }
  12. requirements:
  13. token: \w+
  14.  
  15. myaccount_party_update:
  16. url: /account-party/:token/update
  17. class: sfPropelRoute
  18. options: { model: TpParty, type: object, column: token }
  19. param: { module: myaccount_party, action: Update }
  20. requirements:
  21. sf_method: [put]
  22. token: \w+


we formularzu sie tak odnosze to akcji:

  1. form action="getObject()->isNew() ? '@myaccount_party_create' : '@myaccount_party_update').(!$form->getObject()->isNew() ? '?token='.$form->getObject()->getToken() : '')) ?>" method="post" isMultipart() and print 'enctype="multipart/form-data" ' ?>>
  2. getObject()->isNew()): ?>
  3.  
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.