K
K
Kolya Vantukh2017-01-22 16:46:58
Yii
Kolya Vantukh, 2017-01-22 16:46:58

ActiveCheckboxList (Yii2) how to change value values?

I conclude this way

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

And it turns out like this
<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 can I make sure that the value values ​​contain not a serial number, but a brand name?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2017-01-22
@slo_nik

Good afternoon.
What do you want to change to?
Maybe ArrayHelper() will help you

M
Maxim Timofeev, 2017-01-25
@webinar

Your $brands looks like this:
which is equivalent to this:
The script does not number anything, it takes the keys for value
You probably need to bring your array of values ​​​​to this form:
I can tell you how if you show the code where you form $brands

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question