/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Datablock(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Datablock'])) { $model->attributes = $_POST['Datablock']; if ($model->save()) { if (isset($_GET['ajax'])) { echo 'datablock create suc'; exit; } else { $this->redirect(array('view', 'id' => $model->id)); } } } list($data_block_tree) = $this->getRelData(); $leafs = Category::model()->getCategorySelectData(); $model->p_id = $_GET['p_id']; if (isset($_GET['ajax'])) { $this->renderPartial('create', array('model' => $model, 'data_block_tree' => $data_block_tree, 'leafs' => $leafs), false, true); } else { $this->render('create', array('model' => $model, 'data_block_tree' => $data_block_tree, 'leafs' => $leafs)); } }