I have two classes with a many to many relationship. For this question let’s call them Emp and Roles both were generated with gii. Each Emp can have many roles and they are linked with hasMany and viaTable.
Roles are created and updated with a checkboxlist with the following code:
Thanks. I’ve seen this post in stackoverflow, but couldn’t make it work.
If I implement it as you suggested then the checkboxlist doesn’t get populated. I assume it’s because it is now mapped to the attribute $roles in the Emp class and not to the Emp relationship method getRoles.
We can not use "roles" as an attribute for user input, since we already have "roles" relation. We have to add some attribute with other name to handle user input, "role_ids" for example.