advance search : wildcard search from another model

Hi guys,

I am new to yii framework and need your help to solve my problem…

I have a problem to perform wildcard search from another model…

actually i have two models :

Usr

-usr_id

-usr_name

-dept_id (FK)

public function relations()


{


	// NOTE: you may need to adjust the relation name and the related


	// class name for the relations automatically generated below.


        


        //property name=> array(relations, class nname, key)


	return array(


                'dept'=>array(self::BELONGS_TO, 'UsrDept', 'dept_id'),


	);


}





    


   public function search()


{


	// Warning: Please modify the following code to remove attributes that


	// should not be searched.





	$criteria=new CDbCriteria;





	.


            . 


            .


            $criteria->together = true; 


            $criteria->with = array('dept');


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


            $criteria->addCondition('dept_name LIKE :tn');


            $criteria->params[':tn']=$this->dept.'%';


	return new CActiveDataProvider($this, array(


		'criteria'=>$criteria,


	));


}

UsrDept

-dept_id(PK)

-dept_name


i have a "_search.php" file in usr view and create a field for user to enter text

<?php echo $form->label($model,‘dept_id’); ?>

<?php echo $form->textField($model->dept,‘dept_name’); ?>

and it give me an error

<b>Fatal error</b>: Call to a member function getValidators() on a non-object in <b>D:\xampplite\htdocs\ebooking\framework\web\helpers\CHtml.php</b>

can anyone help me on this…

your helps are very much appreciated.

Hi,

This Wiki article may be helpful.

As for the exact error you get, try to use [color="#1C2837"][size="2"]


<?php echo $form->textField($model,'search_attr'); ?>

[/size][/color]

[color="#1C2837"][size="2"], setting search_attr based on wiki article.

[/size][/color]

[color="#1C2837"][size="2"]Regards[/size][/color]

And welcome to forums :)

thanks a lot …

finally i get my problem solved… thanks again… so much