Load a view from different model in Yii

Hello Guys… I’m starting to use Yii! a couple of months ago…

Now I’m kinda stuck with quite simple problem but i’ve searched online for days with no clear answer for my problem (or because I haven’t searched well… ^_^)…

I have a "Site" and "Member" models (with its corresponding controllers and views) in my small event registration web-app

what I’m trying to do is to render the “Member” model from homepage view ("/views/site/index.php") using the following codes

[font="Courier New"]$model = Member::model();

echo $this->renderPartial(’//member/_form’,array(‘model’=>$model));


that’s supposed to load a registration form (similar form rendered when I’m creating the new ‘member’)

the view is correctly loaded, but when I/user click the “save”/submit button, it doesn’t do anything… I checked the database, and there was no change on it…

the similar form works all fine when it’s loaded from “view/member/create.php” but it doesn’t do anything from homepage (site/index.php)

sorry if my question seems silly … I’m newbie in Yii and need lots of helps from you guys.

Thanks in advance, any help is highly appreciated…


try this one…

echo $this->renderPartial(‘application.views.member._form’,array(‘model’=>$model),true);

I am not sure whether this helps…

I have example, may be can help you

  1. in controller

public function actionIndex()


		$model = $this->newmember();

		$model2= $this->loadModel(); // example

		$this->render('index',array('model'=>$model, 'model2'=>$model2))



	public function newmember()


		$member=new Member();


		if(isset($_POST['ajax']) && $_POST['ajax']==='member-form')


			echo CActiveForm::validate($comment);




		if (isset($_POST['Member']))





				Yii::app()->user->setFlash('newmember','Register successfull');




		return $member;


then in view(index.php) you can cath variabel $model with your code


Thanks for the comment… I tried that out, but it seems it works similar to mine… no new data is filled out to my database…

thanks anyway,

Thanks a lot… It does work great… I bet the change in actionIndex() and new function newmember() really create the difference ^_^… thanks