yii - How can I change the checkboxlist to look similar to on/off switch? -


is there way change checkboxlist widget similar on/off switch presented in kartik's switch input widget, in group?

i'm using code:

echo $form->field($model, 'blocked_list')->checkboxlist($array_list); 

which simple use, produces "simple" list...

i've tried karitk's this:

foreach ($array_list $category_id=>$category_name) {     echo '<label class="control-label">' . $category_name . '</label>';     echo switchinput::widget([         'name'=>'blocked_list',         'value'=>in_array($category_id, $model->blocked_list),         'pluginoptions' => [             'size' => 'mini',         ],     ]); 

but not link model, , form looses format

any ideas, please?

i've got it!

    foreach ($category_array $category_id=>$category_name) {         if ( isset($model->blocked_list[$category_id]) )             $model->blocked_list[$category_id] = true;         else             $model->blocked_list[$category_id] = false;          echo $form->field($model, 'blocked_list[' . $category_id . ']')             ->label($category_name)             ->widget(switchinput::classname(), []); } 

i added validate "if" ask if variable display exists, , set correct value model

hope helps someone


Comments

Popular posts from this blog

java - BeanIO write annotated class to fixedlength -

Using Java 8 lambdas/transformations to combine and flatten two Maps -

How to connect android app to App engine -