Ejemplo n.º 1
0
 public function actionCmsEdit($id)
 {
     $model = new CmsPages();
     // echo "<pre>";print_r($_REQUEST);die;
     $cmsedit = CmsPages::model()->findByAttributes(array('id' => $id));
     // echo "<pre>";print_r($_REQUEST);die;
     if (isset($_POST['CmsPages'])) {
         $model->attributes = $_POST['CmsPages'];
         if ($model->validate()) {
             $res = CMSPages::model()->findByAttributes(array('id' => $id));
             $title = $_REQUEST['CmsPages']['title'];
             $meta = $_REQUEST['CmsPages']['meta_title'];
             $desc = $_REQUEST['CmsPages']['desc'];
             $res->title = $title;
             $res->meta_title = $meta;
             $res->desc = $desc;
             if ($res->save()) {
                 $this->redirect(array('cmslisting'));
             }
         } else {
             $errors = $model->getErrors();
             var_dump($errors);
         }
     }
     $this->render('cmsedit', array('edit' => $cmsedit, 'model' => $model));
 }