public function actionCreate() { $model = new Faq(); $description = new FaqDescription(); if (isset($_POST['FaqDescription'])) { $suc = Yii::t('info', 'Attribute was successfully created'); $err = Yii::t('info', 'Could not update Attribute'); $description->setAttributes($_POST['FaqDescription']); $description->faq_id = 0; $description->locale_code = Yii::app()->getLanguage(); if ($model->validate() && $description->validate()) { if ($model->save()) { $description->faq_id = $model->id; $description->save(); Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, $suc); if (Yii::app()->getRequest()->getIsAjaxRequest()) { $this->renderPartial('_view', array('model' => $model), false, true); Yii::app()->end(); } else { $this->redirect(array('view', 'model' => $model)); } } else { Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, $err); } } } $this->render('create', array('model' => $model, 'description' => $description, 'title' => $description)); }
public function actionEditFaq($id) { $model = new Faq(); $rec = Faq::model()->findByPk($id); if (isset($_POST['Faq'])) { $model->attributes = $_POST['Faq']; if ($model->validate()) { $q = $_REQUEST['Faq']['question']; $ans = $_REQUEST['Faq']['answer']; $res = Faq::model()->findByPk($id); $res->question = $q; $res->answer = $ans; if ($res->save(false)) { $this->redirect(array('faqlisting')); } } else { $errors = $model->getErrors(); } } $this->render('editfaq', array('model' => $model, 'edit' => $rec)); }