Cactivedataprovider Property Not Defined In Textbox


I am trying to get the property from CActiveDataProvider to textfield.

Here is my model:

public function findMitraFromMitraLokasi($mitra_id){

$criteria = new CDbCriteria;

       $criteria->select =',



                t.nama_depan AS nama_depan,

                t.nama_belakang AS nama_belakang,








        $criteria->condition = ' <> :id';

        $criteria->params = array(':id' => $mitra_id);

        $criteria->order = 't.no_anggota ASC';

        return new CActiveDataProvider('Mitra', array('criteria' => $criteria));


Here is my controller:

public function actionAdmin($mitra_id)


        if(isset($mitra) && !empty($mitra)){

                    $model = Mitra::model()->findMitraFromMitraLokasi($mitra_id);

                    $tipe = true;



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

                'model' => $model,




Here is my views:

1. admin1 view:

<div class="search-form" style="display:none">

        <?php $this->renderPartial('_search', array(

        'model' => $model,

    )); ?>



$this->widget('zii.widgets.grid.CGridView', array(

    'id' => 'mitra-grid',

    'dataProvider' => $model,

    'columns' => array(










2. _search view:

<div class="search-form" style="display:none">

    <div class="wide form">


        $form = $this->beginWidget('CActiveForm', array(

            'action' => Yii::app()->createUrl($this->route),

            'method' => 'get',




                <div class="controls">

                    <?php echo $form->textField($model, 'nama_depan', 

                              array('size' => 50, 'maxlength' => 50)); ?>


        <?php $this->endWidget(); ?>



I got the following error (also attached):

Property "CActiveDataProvider.nama_depan" is not defined.

I confused with the above error because when I remark the search, the gridview is displaying the data.

Is there something missing? Please do help this noob :slight_smile:

Thanks in advance…

Check that nama_depan is in table ,& is defined in model rules,I think it is issue of 1 of it.

If still error,

try to put in a validation rule,search safe, on=>findMitraFromMitraLokasi($mitra_id)

Dear Abhishek,

I’ve checked the table and its rules in the model. It’s already defined in the table and there’s no rule regarding nama_depan.


[color="#006400"]/* Moved from "Bug Discussions" to "General Discussion for Yii 1.1.x" */[/color]

Hi Andy,

In your _search view, $model is assumed to be a model instance, but you have passed the instance of CActiveDataProvider with the name of "model" from the controller to the view.

CActiveDataProvider is not a model.

Please take a look at this wiki article.

Hi Softark,

My mistake :slight_smile: I got your point. Thanks for your solution…