Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Nng\Frontend\Controllers;
- use Nng\Frontend\Forms\AddPollForm;
- use Nng\Frontend\Models\Poll;
- use Phalcon\Exception;
- class PollController extends ControllerBase
- {
- public function initialize()
- {
- parent::initialize();
- }
- public function indexAction()
- {
- }
- public function addAction()
- {
- $form = new AddPollForm();
- $poll = new Poll();
- $form->bind($_POST, $poll);
- if($form->isValid()){
- $poll->topic = $this->request->getPost("topic");
- if($poll->save()===false){
- foreach($poll->getMessages() as $m){
- echo $m;
- $this->flash->error($m);
- }
- }else{
- $this->flash->success('опрос успешно добавлен');
- }
- }else{
- foreach($form->getMessages() as $m){
- $this->flash->error($m);
- }
- }
- $this->view->setParamToView('form', $form);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement