S
S
SwoDs2016-01-18 17:50:57
Yii
SwoDs, 2016-01-18 17:50:57

Update checkboxList() how to make values ​​checked - Yii2?

I have Promotions and Restaurants hasMany connection between them.
When creating a new promotion, there are no problems, I select the restaurants I need in the checkboxList(), then I get an array of IDs of these restaurants and already make entries in the relay table.
The problem is in editing, you need to put checkboxes in the existing list of restaurants checkboxList () for those restaurants that were marked earlier when creating.
Of the options, I have only found the use of options: item for checkboxList (), but then you need to rewrite the entire display of checkboxes, in my opinion this is not the best approach.
I also thought about using itemOptions, but unfortunately it does not contain such a parameter as checked, it is taken out by 2 parameters in checkbox ()
Maybe there is a simpler solution or have I missed something?
--------------------------
Somehow, in the end, everything just turned out to be simple, and I don’t understand how I missed it ... it was enough just to pass a list of IDs that should be checked into the class variable that is responsible for this list ... But I learned a lot about the checkboxList() and checkbox( ), solved one display problem =)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita, 2016-01-18
@SwoDs

stackoverflow.com/questions/23087963/how-to-have-y...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question