public function parents($lang) { $parents_id = AuthorityRelation::model()->findAll('id2=:id', array(':id' => $this->id)); $parents = array(); foreach ($parents_id as $id) { $parent = $this->findByPk(array('id' => $id->id1, 'lang' => $lang)); array_push($parents, $parent); } return $parents; }
public function actionAuthrel() { $lang = $this->language; $model = new AuthorityRelation(); // uncomment the following code to enable ajax-based validation /* if(isset($_POST['ajax']) && $_POST['ajax']==='authority-type-atypes-form') { echo CActiveForm::validate($model); Yii::app()->end(); } */ $err = ""; if (isset($_POST['AuthorityRelation'])) { $model->attributes = $_POST['AuthorityRelation']; if ($model->validate()) { // form inputs are valid, do something here try { $model->save(); } catch (Exception $e) { $err = "some error " . $e->getMessage(); } } } $auth = Authority::model()->findAll("lang=:lang", array(":lang" => $lang)); $this->render('authrel', array('model' => $model, 'auth' => $auth, 'err' => $err)); }