How Do I Change Default Representation Of Checkbox/radio Lists?

Hello! I would like active field to render checkbox/radio lists in a specific way (as Bootstrap’s button groups)

Currently I create those fields like this


                echo $form->field($model,'foo')->inline()->checkboxList

                (

                    $fooList,

                    [

                        'class' => 'btn-group',

                        'data-toggle' => 'buttons',

                        'item' => function ( $index , $label , $name , $checked , $value )

                        {

                            return Html::checkbox

                            (

                                $name,

                                $checked,

                                [

                                    'value' => $value,

                                    'label' => $label,

                                    'container' => false,

                                    'labelOptions' =>

                                    [

                                        'class' => $checked ? 'btn btn-primary active' : 'btn btn-primary',

                                    ],

                                ]

                            );

                        }

                    ]

                );

What is the right way to achieve this behavior application-wide?

Create a widget.

Thank you, I’ve got it.