Mere pass 2 models hain un main se ek hai users.php or ek hai country.php do no main 1:n (Has Many Relationship banaya hai).
Users.php
id
username
country_id
Country.php
id
country
ab men User ke admin.php main country ko id ke sath nahe per country name ke saath search karwana chahta hun.
Users ke model main Search method ke code ye hai
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('name',$this->name,true);
$criteria->compare('username',$this->username,true);
$criteria->compare('email',$this->email,true);
$criteria->compare('password',$this->password,true);
$criteria->compare('country_id',$this->country_id);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
or views main
_search.php
ka code ye hai
<div class="row">
<?php echo $form->label($model,'country_id'); ?>
<?php echo $form->textField($model,'country_id'); ?>
</div>
Thanx.
Mansoor Samo