S
S
serikd2016-05-06 11:04:56
Yii
serikd, 2016-05-06 11:04:56

How do you implement the logic of adding/updating multicategories in Yii2?

Before version 2.0.8, I implemented additional getter and setter. properties.
The getter gets the selected categories, while the setter simply sets the value. Example #issuecomment-44921519
With this case, I used eachValidator with the integer rule, but in version 2.0.8 it swears that catIds should be an integer, I didn’t get into the code, I didn’t look at what they changed there.
For myself, I see the following solutions:
1) Remove getters and setters, make the catIds public property and fill it in the afterFind() method
2) Apply the intval filter to eachValidator (have not tried it yet)
3) Roll back to version 2.0.7 :)
And how you implement such logic? Maybe there are nice solutions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Arutyunov, 2016-05-06
@arutyunov

https://github.com/yii2tech/ar-linkmany watched this behavior? Alexander Makarov
recommended it to me for working with many-to-many connections. Before that, I used a public property and afterFind(), afterSave(), etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question