I have 2 related tables and a call applicant and another call requests, i want that on application CGridView show me identification card, name and lastname of the applicant, but the problem comes when i relate the Search () function of the model, because in the CGridView I have to put the name => applicant_id both cedula, name, lastname because that is their relationship but it starts throwing 500 error when i search in the filter.
Code of CGridView
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'request-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array ('header'=>Yii::t('app','Number'),'name'=>'id','value'=>'$data->id','type'=>'text'),
array ('header'=>Yii::t('app','IdentificationCard'),'name'=>'applicant_id','value'=>'$data->applicant->identificationcard','type'=>'text'),
array ('header'=>Yii::t('app','Name'),'name'=>'applicant_id','value'=>'$data->applicant->name','type'=>'text'),
array ('header'=>Yii::t('app','LastName'),'name'=>'applicant_id','value'=>'$data->applicant->lastname','type'=>'text'),
array ('header'=>Yii::t('app','Date'),'name'=>'date','value'=>'$data->date','type'=>'text'),
array ('header'=>Yii::t('app','Description'),'name'=>'description','value'=>'$data->description','type'=>'text'),
array ('header'=>Yii::t('app','Status'),'name'=>'status','value'=>'Request::model()->getStatus($data->id)','type'=>'text')
Code of the function Search() in model:
public function search()
{
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('fecha', $this->date, true);
$criteria->compare('descripcion', $this->description);
$criteria->compare('estatus',$this->status);
$criteria->with = array('solicitantes');
$criteria->addSearchCondition('LOWER(applicant.identificationcard)', strtolower((string)$this->applicant_id));
$criteria->addSearchCondition('LOWER(applicant.name)',sstrtolower((string)$this->applicant_id));
$criteria->addSearchCondition('LOWER(applicant.lastname)', strtolower((string)$this->applicant_id));
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'pagination'=>false,
));
}