Пример #1
0
 /**
  * Edits a Profile Field Category
  */
 public function actionEditCategory()
 {
     $id = (int) Yii::app()->request->getQuery('id');
     $category = ProfileFieldCategory::model()->findByPk($id);
     if ($category == null) {
         $category = new ProfileFieldCategory();
     }
     $category->translation_category = $category->getTranslationCategory();
     // uncomment the following code to enable ajax-based validation
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'admin-userprofile-editcategory') {
         echo CActiveForm::validate($category);
         Yii::app()->end();
     }
     if (isset($_POST['ProfileFieldCategory'])) {
         $_POST = Yii::app()->input->stripClean($_POST);
         $category->attributes = $_POST['ProfileFieldCategory'];
         if ($category->validate()) {
             $category->save();
             $this->redirect(Yii::app()->createUrl('//admin/userprofile'));
         }
     }
     $this->render('editCategory', array('category' => $category));
 }