Пример #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Attr();
     $model->pos = '1';
     $model->type = '1';
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Attr'])) {
         $model->attributes = $_POST['Attr'];
         if ($_POST['Attr']['pos'] == '1') {
             $groups = Attr::model()->findAllByAttributes(array('attr_group_id' => $_POST['Attr']['attr_group_id']));
             $maxpos = 0;
             foreach ($groups as $group) {
                 if ($group->pos > $maxpos) {
                     $maxpos = $group->pos;
                 }
             }
             $model->pos = $maxpos + 1;
         }
         if (Yii::app()->params['server'] == CAlexHelper::DEVELOPMENT) {
             if ($model->save()) {
                 echo 'success';
             }
         }
         return;
     }
     $this->render('create', array('model' => $model));
 }
Пример #2
0
 /**
  * 录入属性
  */
 public function actionCreate()
 {
     parent::_acl();
     $model = new Attr();
     if (isset($_POST['Attr'])) {
         $model->attributes = $_POST['Attr'];
         if ($model->save()) {
             AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入属性,ID:' . $model->id));
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }