Example #1
0
 /**
  * Add action method
  *
  * @return void
  */
 public function add()
 {
     $this->prepareView('forms/add.phtml');
     $this->view->title = 'Forms : Add';
     $fields = $this->application->config()['forms']['Phire\\Forms\\Form\\FormObject'];
     $this->view->form = new \Pop\Form\Form($fields);
     $this->view->form->setAttribute('id', 'form-form');
     $this->view->form->setIndent('    ');
     if ($this->request->isPost()) {
         $this->view->form->addFilter('htmlentities', [ENT_QUOTES, 'UTF-8'])->setFieldValues($this->request->getPost());
         if ($this->view->form->isValid()) {
             $this->view->form->clearFilters()->addFilter('html_entity_decode', [ENT_QUOTES, 'UTF-8'])->filter();
             $form = new Model\Form();
             $form->save($this->view->form->getFields());
             $this->view->id = $form->id;
             $this->sess->setRequestValue('saved', true);
             $this->redirect(BASE_PATH . APP_URI . '/forms/edit/' . $form->id);
         }
     }
     $this->send();
 }