public function actionSeo() { //empty object by default $seo = null; //find all seo in db $seoArr = LuxSeo::model()->findAll(); //if array not empty if (!empty($seoArr)) { //get first $seo = $seoArr[0]; } else { //create new array $seo = new LuxSeo(); $seo->save(); } //render form $this->render('seo', array('seo' => $seo)); }