Creating Model Issue

Hi,

I am going through the following steps to create a mode, controller and view from scratch I have followed the below steps:

1- Created Controller with Yiic Shell —> (then) controller Message show edit

2- Then I went ahead and create model in protected/models/ folder named as MessageForm

3- Then I am using the controller on actionShow to make and object of MessageForm and sending to view as

$this->render(‘show’,array(‘message’=>$model)

but Unfortunately I cannot see anything on the view but some garbled chinese characters and when I view the page source

I see my model class code is embeded in it, why does that happened?

and then when I tried in controller class actionShow method to make and send the object of ContactForm which was created during yiic webapp command then it worked fine.

Could you please tell me why cannot I make a model class manually or do I have to register it somewhere so that my controller

class can send it to the view ?

In the line

$this->render(‘show’,array(‘message’=>$model)

you are missing the closing ) of the function render

It was a typo in the post here, but here is the actual code of controller

<?php

class MessageController extends Controller

{

public function actionShow()


{


	&#036;model = new RhmForm;





	&#036;this-&gt;render('show',array('message'=&gt;&#036;model));





}





public function actionEdit()


{


	&#036;this-&gt;render('edit');


}





public function actionIndex()


{


	&#036;this-&gt;render('index');


}

}

and the code of model class is

<?php

class RhmForm extends CFormModel

{

public &#036;name;





public function rules()


{


	return array(





		array('name', 'required'),


	


	);


}

}

?>

this line


$this->render('show',array('message'=>$model));

calls a view show.php

paste that code to see if there is something wrong…

NOTE: use the code directive ([ code] and [ /code] - without spaces) for the code… it’s easier to read…

Thanks for the code tip, well here is the show.php code which resides in /protected/views/message


<h1> This is testing message </h1>


<p> 


<?php echo $message->name; ?> 


</p> 




Is there anything I missed?

Don’t really know what’s the problem… the code is good… I just tried it and it’s working for me…

(I just copy/pasted your code for the cotroler,model and view so the code is OK)

:( Thats Strange

Which version of Yii you’re using ?

Yii 1.1.2…

have you checked the Yii requirements?

try to call render without the model just to see if that’s working… like




public function actionShow()

	{

   $this->render('show');

}



Yes it works like that , I mean




$this->render('show');


$this->render('show',array('message'=>'hello world'));



Both works but only when I use my own model class it stops working

can you do a remote session to my pc, I am adding my id is ehunt2002

Just got it that it was the code editors problem