Fatal error: Call to a member function search() on a non-object

My page displays without any debug error but then it has this at the bottom:

Fatal error: Call to a member function search() on a non-object in C:\wamp\www\YiiTest\protected\views\site\index.php on line 6

I did the following: I tried to access the project controller/model from the index site of the site controller. To do this I put the following into the site controller:

public function actionIndex() {

    $model = new project('search');


    if (isset($_GET['project']))


        $model->attributes = $_GET['project'];





    $this->render('index', array(


        'model' => $model,


    ));

}

In the project model there is a function called search:

public function search()

{


	$criteria=new CDbCriteria;


	$criteria->compare('id',$this->id);


	$criteria->compare('user_id',$this->user_id);


	$criteria->compare('title',$this->title,true);


	$criteria->compare('description',$this->description,true);


	$criteria->compare('fundgoal',$this->fundgoal);


	return new CActiveDataProvider(get_class($this), array(


		'criteria'=>$criteria,


	));


}

The call in the index file of the site directory is like this:

<?php $this->widget(‘zii.widgets.grid.CGridView’, array(

'id'=&gt;'project-grid',


'dataProvider'=&gt;&#036;model-&gt;search(),


'filter'=&gt;&#036;model,


'columns'=&gt;array(








	'title',


	'description',








),

)); ?>

Everything is displayed correctly, but this error message is at the bottom of the page. Do you have any suggestions what could be causing this? Am I doing something wrong in accessing a ‘different model’ (the project model from the site directory)?

thanks

Nicolas

From the error it would mean that $model is not an object… but as you say if the data is displayed correctly then $model-search() is called at least one time to display that data…

When you say that everything is displayed correctly does it mean that you get the CGridView displayed? Does the search/filtering work on it?

NOTE: when posting code… so that it’s more readable… use the <> button in the editor or put your code inside the directives [code ] and [/code ] … (without spaces)

The problem seems to have come from the fact that the model name didn’t start with a capital letter. I was using an extension that upgraded the Gii (FullCrud) which had a slight bug in it.

thanks

Nicolas