public function actionCreate() { $model = new Category; $lang_model = new LanguageModel; $CadDescModel = new CategoryDescription; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $allLangs = $lang_model->findAll('1', array('order' => 'id ASC')); $language = $lang_model->find("code='de'"); $aCategories = Category::model()->generateTreeList(); if (isset($_POST['Category'])) { $model->attributes = $_POST['Category']; if ($model->save()) { $pk = $model->getPrimaryKey(); foreach ($_POST['CategoryDescription']['category_name'] as $langId => $catName) { $cat_desc_model = new CategoryDescription; $cat_desc_model->attributes = array( 'category_id' => $pk, 'category_name' => $catName, 'language_id' => $langId, ); $cat_desc_model->save(); } $this->redirect(array('index', 'category_id' => $model->category_id)); } } $this->render('create', array( 'model' => $model, 'aCategories' => $aCategories, 'allLangs' => $allLangs, 'CadDescModel' => $CadDescModel, )); }