/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     if ($this->menu_use[3]) {
         $model = new NewsGroup();
         // Uncomment the following line if AJAX validation is needed
         // $this->performAjaxValidation($model);
         $news_type_list = array();
         $criteria = new CDbCriteria();
         $criteria->condition = 'status=:status AND news_type_id<>2 AND news_type_id<>3';
         $criteria->params = array(':status' => 1);
         $criteria->order = 'sort_order';
         $news_type = NewsType::model()->findAll($criteria);
         foreach ($news_type as $type) {
             $news_type_list[$type->news_type_id] = $type->name_th;
         }
         if (isset($_POST['NewsGroup'])) {
             $model->attributes = $_POST['NewsGroup'];
             if ($model->save()) {
                 $this->redirect(array('index'));
             }
         }
         $this->render('create', array('model' => $model, 'news_type_list' => $news_type_list));
     } else {
         $this->redirect(array('site/index'));
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     if ($this->menu_use[3]) {
         $model = new NewsGroup();
         // Uncomment the following line if AJAX validation is needed
         // $this->performAjaxValidation($model);
         if (isset($_POST['NewsGroup'])) {
             $_POST['NewsGroup']['news_type_id'] = 1;
             $model->attributes = $_POST['NewsGroup'];
             if ($model->save()) {
                 $this->redirect(array('index'));
             }
         }
         $this->render('create', array('model' => $model));
     } else {
         $this->redirect(array('site/index'));
     }
 }