Model:
1. Add filter attributes
VaR $ A = "";
VaR $ B = "";
2. modify the configuration in the Rules Method
Array ('......., A, B ', 'safe', 'on' => 'search ');
3. Pay attention to the relations Method
Public Function relations ()
{
// Note: you may need to adjust the relation name and the related
// Class name for the relations automatically generated below.
Return array (
'Xxx' => array (SELF: has_one, 'xxxmodel', array ('... '=> '.... ')),
);
}
4. Modify the search () method to Add rows
$ Criteria-> compare ('xxx. Ax ', $ this-> );
$ Criteria-> compare ('xxx. bx ', $ this-> B );
View
1. 'dataprovider' => $ model-> with ("XXX")-> Search (),
2. Column Display Modification
Array (
'Name' => 'A ',
'Value' => '$ data-> XXX-> ax ',
'Filter' => array (select down menu array ),
),
Array (
'Name' => 'B ',
'Value' => '$ data-> XXX-> BX ',
'Filter' => array (1 => "set", 0 => 'not set '),
),
Code prompt:
1. The added two attributes are only used to record the search conditions on the page.
2. The cdbcriteria Search Method in the search method has not changed. Learn how to use associated search
Yii framework FAQ: how to solve the filter problem of cgridview joined table fields