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 :




-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->addCondition('dept_name LIKE :tn');


	return new CActiveDataProvider($this, array(







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.


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


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



And welcome to forums :)

thanks a lot …

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