Cactivedataprovider Property Not Defined In Textbox

Hi,

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.id,

                t.no_anggota,

                t.unit_id,

                t.nama_depan AS nama_depan,

                t.nama_belakang AS nama_belakang,

                t.no_identitas,

                t.no_telepon_rumah,

                t.no_hp,

                t.no_hp1,

                t.email,

                t.tgl_bergabung';

       

        $criteria->condition = 't.id <> :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,

    )); ?>

    </div>


<?php


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

    'id' => 'mitra-grid',

    'dataProvider' => $model,

    'columns' => array(

        'no_anggota',

        'nama_depan',

        'nama_belakang',

        'email',

        'no_hp'),

    ),

);

?>

</div>



2. _search view:


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


    <div class="wide form">

        <?php

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

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

            'method' => 'get',

        ));

        ?>


        <fieldset>

                <div class="controls">

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

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

                </div>

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


    </div>

</div>

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.

Thanks…

[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.

http://www.yiiframework.com/wiki/381/cgridview-clistview-and-cactivedataprovider

Hi Softark,

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

Cheers!