/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($id) { $model = new LinksTranslation(); if ($id) { $model->id_links = $id; } // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['LinksTranslation'])) { $model->attributes = $_POST['LinksTranslation']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id_links_translation)); } } $this->render('create', array('model' => $model)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Links(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Links'])) { $model->attributes = $_POST['Links']; $model->id_creator = Yii::app()->user->id; if ($model->save()) { $linkTranslation = new LinksTranslation(); $linkTranslation->id_language = 1; $linkTranslation->name = $model->name; $linkTranslation->link_to = $model->link_to; $linkTranslation->id_links = $model->id_links; $linkTranslation->save(); $this->redirect(array('view', 'id' => $model->id_links)); } } $this->render('create', array('model' => $model)); }