I have a 3 tables:
-
Programs (Programs Tbl)
-
Payments (TblPayments)
-
Table linking the two above, as the one product can have multiple payments (TblPaymentDict)
Relations:
programs:
‘tblPayment’ => array (self :: MANY_MANY, ‘TblPayment’, ‘tbl_payment_dict (id_program, id_payment)’)
payments:
‘programs’ => array (self :: MANY_MANY, ‘TblPrograms’, ‘tbl_payment_dict (id_payment, id_program)’)
And I have the CGridView with program list, where each program, in the column ‘payments’ can have more than one option (why I have TblPaymentDict). It works. If a program has more than one payments method, then user can see it.
It does not work with filtering.
array (
‘name’ => ‘id_payment’
‘filter’ => $ model-> getPaymentList ()
‘value’ => ‘$ data-> getRelatedPayments ()’,
)
getPaymentList public function ()
{
$payArray = CHtml::listData(TblPayment::model()->findAll(array(‘order’ => ‘name’, “condition”=>“is_active = 1”)), ‘id’, ‘name’);
return $ payArray ;
}
public function getRelatedPayments() {
$out=CHtml::listData($this->tblPayment,‘id’,‘name’);
return implode(’, ', $out);
}
Don’t know what is the problem with. With wrong filtering method, relations, or mayble with search function:
$criteria=new CDbCriteria;
$criteria->compare(‘id’,$this->id);
$criteria->compare(‘name’,$this->name,true);
$criteria->compare(‘id_category’,$this->id_category);
$criteria->compare(‘id_subcategory’,$this->id_subcategory);
$criteria->compare(‘id_payment’,$this->tblPayment);
$criteria->compare(‘description’,$this->description,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
Help