mardi 3 novembre 2015

Yii2 Checkboxlist not checked on update

Checkboxlist is not selected during update. here is my code.

if(!$model->isNewRecord)
    $list2 = ArrayHelper::map($tax_rule_group_shop->find()->where("id_tax_rules_group =".$model->id_tax_rules_group)->all(),'id_shop','id_shop'); 
 else
    $list2 = array(); 

     $tax_rule_group_shop->id_shop = $list2;
     $listdata=ArrayHelper::map(Shop::find()->all(),'id_shop','name'); ?>
    <?= $form->field($tax_rule_group_shop, 'id_shop[]')->checkboxList($listdata,$list2)->label('Shops');?

What is the problem in this code?

If i use Chtml::checkbox it is working but as usual validations are not working.

<?= Html::checkboxList('id_shop', $list2, $listdata, ['itemOptions'=>['class' => 'test']]); ?>




Aucun commentaire:

Enregistrer un commentaire