Advertisement
Guest User

Untitled

a guest
Aug 20th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Nng\Frontend\Controllers;
  4.  
  5.  
  6. use Nng\Frontend\Forms\AddPollForm;
  7. use Nng\Frontend\Models\Poll;
  8. use Phalcon\Exception;
  9.  
  10. class PollController extends ControllerBase
  11. {
  12. public function initialize()
  13. {
  14. parent::initialize();
  15. }
  16.  
  17. public function indexAction()
  18. {
  19. }
  20.  
  21. public function addAction()
  22. {
  23. $form = new AddPollForm();
  24. $poll = new Poll();
  25. $form->bind($_POST, $poll);
  26.  
  27. if($form->isValid()){
  28. $poll->topic = $this->request->getPost("topic");
  29. if($poll->save()===false){
  30. foreach($poll->getMessages() as $m){
  31. echo $m;
  32. $this->flash->error($m);
  33. }
  34. }else{
  35. $this->flash->success('опрос успешно добавлен');
  36. }
  37. }else{
  38. foreach($form->getMessages() as $m){
  39. $this->flash->error($m);
  40. }
  41. }
  42.  
  43.  
  44.  
  45. $this->view->setParamToView('form', $form);
  46. }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement