Ejemplo n.º 1
0
 public function createAction()
 {
     $form = new CategoryForm();
     $category = new Category();
     $data = $this->request->getPost();
     if (!$form->isvalid($data, $category)) {
         foreach ($form->getMessages() as $message) {
             $this->flash->error($message);
         }
         return $this->forward("category/new");
     }
     if (!$category->save()) {
         foreach ($category->getMessages() as $message) {
             $this->flash->error($message);
         }
         return $this->forward("category/new");
     }
     $form->clear();
     $this->flash->success("提交成功");
     return $this->forward("category/index");
 }