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;






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




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

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








)); ?>

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)?



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.