Ejemplo n.º 1
0
 public function restPostBlog()
 {
     $postData = $this->params()->fromPost();
     $form = new Form\PostCreateForm();
     $form->useSubFormGroup()->bind($postData);
     $callback = $this->params()->fromPost('callback', '/pa/');
     if ($form->isValid()) {
         $postData = $form->getData();
         $itemModel = Api::_()->getModel('Blog\\Model\\Post');
         $postId = $itemModel->setItem($postData)->createPost();
         $this->flashMessenger()->addMessage('post-create-succeed');
         $this->redirect()->toUrl($callback . $postId);
     } else {
     }
     return array('form' => $form, 'post' => $postData);
 }
Ejemplo n.º 2
0
 public function restPostBlog()
 {
     $postData = $this->params()->fromPost();
     $form = new Form\PostCreateForm();
     $form->useSubFormGroup()->bind($postData);
     if ($form->isValid()) {
         $postData = $form->getData();
         $itemModel = Api::_()->getModel('Blog\\Model\\Post');
         $user = \Core\Auth::getLoginUser('Auth_Admin');
         $postData['user_id'] = $user['id'];
         $postData['user_name'] = $user['userName'];
         $postId = $itemModel->setItem($postData)->createPost();
         $this->flashMessenger()->addMessage('post-create-succeed');
         $this->redirect()->toUrl('/admin/blog/' . $postId);
     } else {
         p($postData);
         p($form->getMessages());
         //p($form->getElements(), 1);
         foreach ($form->getFieldsets() as $fieldset) {
             //   p($fieldset->getMessages());
             //    p($fieldset->getElements());
         }
     }
     return array('form' => $form, 'post' => $postData);
 }