简体   繁体   中英

Yii CGridVIew filter dropdown with relations

I'm using Yii 1.1.16 and in my CGridView, i'm adding a custom filter dropdown. But in the dropdown the value is set, but not the text. any idea why?

here is the html

<select name="Comments[make]">
<option value=""></option>
<option value="02"></option>
<option value="33"></option>
<option value="31"></option>
</select>

in my CGridView i have this

array(
            'name'=>'make',
            'filter'=>array_map("strtoupper", CHtml::listData(Posts::model()->with('abc')->findAll(array('group'=> 'abc.make')), 'id', 'abc.make')),
            'value'=>'strtoupper($data->_abc->make)',
        ),

and in my Posts.php model i have this

/**
 * @return array relational rules.
 */
public function relations()
{
        'abc' => array(self::HAS_MANY, "Abc", array("make_code" => "make_code", "model_code"=>"model_code")),
    );
}

Try This;-

In ListData

 CHtml::listData(Posts::model()->with('abc')->
     findAll(array('condition'=>'group="abc.make"')),
  'id', 'abc.make')

Try this

 'filter'=>array_map( CHtml::listData(Posts::model()->with('abc')->
  findAll(array('group'=> 'abc.make')), 'id', 'abc.make')),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM