在Yii 2.0里面, 怎样自定义checkboxList和radioList样式:
// 输出bootstrap单行样式的radio
<?=$form->field($fieldModel, 'is_show_list')->radioList([1=>'是',0=>'否'],['itemOptions'=>['labelOptions'=>['class'=>'radio-inline']]]); ?>
// 输出bootstrap多行样式的radio
<?=$form->field($model, 'is_show_list')->radioList([1=>'是',0=>'否'],['item'=>function($index, $label, $name, $checked, $value){
return '<div class="radio"><label>'. '<input type="radio" name="'.$name.'" value="'.$value.'" '.($checked?"checked":"").'>'.ucwords($label).'</label></div>';
}]); ?>
// 输出bootstrap单行样式的checkbox
<?=$form->field($fieldModel, 'is_show_list')->checkboxList([0=>'红',1=>'黑',2=>'黄'],['itemOptions'=>['labelOptions'=>['class'=>'checkbox-inline']]]); ?>
// 输出bootstrap多行样式的checkbox
<?=$form->field($model, 'like')->checkboxList([0=>'红',1=>'黑',2=>'黄'],['item'=>function($index, $label, $name, $checked, $value){
return '<div class="radio"><label>'. '<input type="checkbox" name="'.$name.'" value="'.$value.'" '.($checked?"checked":"").'>'.ucwords($label).'</label></div>';
}]); ?>