The usage of the yii2 check box is as follows. The brand in the product is displayed on the page as an example.
Method 1:UseActiveform: checkboxlist ()(This method generates check boxes for all the data obtained in the background)The usage is as follows:
<? PHP $ form = activeform: Begin ()?>
<? PHP echo $ form-> field ($ brand_model, 'brand _ name')-> checkboxlist (arrayhelper: Map ($ brand_info, 'brand _ id ', 'brand _ name')?>
<? PHP activeform: end ();?>
Method 2:UseHTML: activecheckboxlist ()(This method generates check boxes for all the data obtained in the background)The usage is as follows:
<? PHP $ form = activeform: Begin ([])?>
<? PHP echo HTML: activecheckboxlist ($ brand_model, 'brand _ name', arrayhelper: Map ($ brand_info, 'brand _ id', 'brand _ name')?>
<? PHP activeform: end ();?>
Method 3:UseActiveform: checkbox ()(This method generates only one check box)
Method 4:UseHTML: activecheckbox ()(This method generates only one check box)
Description of parameters: $ brand_model -------------- product brand instance Model
Brand_id ------------------- value of the check box
NAME value of the brand_name ------------- check box