/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new MProduct(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $model->status = 1; if (isset($_POST['MProduct'])) { $model->attributes = $_POST['MProduct']; $model->created_date = time(); $model->created_by = Yii::app()->user->id; if ($model->save()) { $this->redirect(array('admin')); } } $brands = CHtml::listData(MCompany::model()->findAll(), 'id', 'name'); $productTypes = CHtml::listData(MProductType::model()->findAll(), 'id', 'name'); $this->render('create', array('model' => $model, 'brands' => $brands, 'productTypes' => $productTypes)); }