コード例 #1
0
 public function actionUpdate($id)
 {
     $model = new CategoryForm();
     if (isset($_POST['CategoryForm'])) {
         $model->attributes = $_POST['CategoryForm'];
         if ($model->validate()) {
             $model->save();
             $this->redirect(array('index'));
         }
     } else {
         $model->loadDataFromCategory($id);
     }
     $statuses = array(0 => Yii::t('common', 'Disabled'), 1 => Yii::t('common', 'Enabled'));
     $stores = CHtml::listData(Store::model()->findAll(), 'store_id', 'name');
     $stores[0] = Yii::t('store', 'Default');
     $this->render('update', array('model' => $model, 'stores' => $stores, 'statuses' => $statuses));
 }
コード例 #2
0
 /**
  * Save changes to a category.
  */
 function updateCategory($args, &$request)
 {
     $categoryId = $request->getUserVar('categoryId') === null ? null : (int) Request::getUserVar('categoryId');
     if ($categoryId === null) {
         $this->validate();
         $category = null;
     } else {
         $categoryId = (int) $categoryId;
         $this->validate($categoryId);
         $category =& $this->category;
     }
     $this->setupTemplate($request, $category);
     import('classes.journal.categories.CategoryForm');
     $categoryForm = new CategoryForm($category);
     $categoryForm->readInputData();
     if ($categoryForm->validate()) {
         $categoryForm->execute();
         Request::redirect(null, null, 'categories');
     } else {
         $templateMgr =& TemplateManager::getManager();
         $templateMgr->append('pageHierarchy', array(Request::url(null, 'admin', 'categories'), 'admin.categories'));
         $templateMgr->assign('pageTitle', $category ? 'admin.categories.editTitle' : 'admin.categories.createTitle');
         $categoryForm->display();
     }
 }