kitune
(Shinkitune)
1
Hi!
I have this tables:
Products
id_product
name
slug
price
Related
id_related
id_product
id_pruduct_2
Wich means that one product (id_product) has multiple related products (id_product_2)
Ok, I need to populate a check box with array_keys($model->related_products),
In relations, of Prodcuts I have:
public function relations()
{
return array(
'related_products'=>array(self::MANY_MANY, 'Products',
'Related(id_product, id_product_2)'),
);
}
There are something wrong, the results are not correct.
Thanks.
kitune
(Shinkitune)
2
Ok, the relations seems works fine, the output of:
foreach($model->related_products as $rel){
echo $rel->id_product;
}
it’s the desidered.
Now, my problem is in the checkbox widget.
<div class="row">
<?php echo CHtml::checkBoxList("related_products",
array_keys($model->related_products),
CHtml::listData(Products::model()-> findAll(array('order' => 'name ASC')), 'id_product','name'),
array('template'=>'<div class="casilla">{input}{label}</div>',
'separator'=>'')
); ?>
</div>
How can I do to tell a checkBoxList the list of id’s?
kitune
(Shinkitune)
3
solved with CList() and ->toString()