I make a conclusion in this way

echo Html::activeCheckboxList($model,'brand',$brands) 

And it turns out in such

 <label><input type="checkbox" name="Search[brand][]" value="1"> Asus</label> <label><input type="checkbox" name="Search[brand][]" value="2"> Acer</label> <label><input type="checkbox" name="Search[brand][]" value="3"> Lenovo</label> 

How to make it so that in the values ​​of value there is not a serial number, but a brand name?

    1 answer 1

    Like that:

     $brands = ['Asus', 'Acer', 'Lenovo']; $itemBrands = []; array_walk($brands, function ($item) use(&$itemBrands) { $newBrands[$item] = $item; }); echo Html::activeCheckboxList($model, 'brand', $itemBrands); 

    Or if you have, for example, the Brand model in which the name field stores the brand name (Asus, Acer, etc.), you can do this:

     use yii\helpers\ArrayHelper; $brands = ArrayHelper::map(Brand::find()->all(), 'name', 'name'); echo Html::activeCheckboxList($model, 'brand', $brands);