Hi. I'm having a little trouble getting a deep relationship to update when I save.
Model_User has one Model_Profile, and Model_Profile is many to many with Model_Department.
I've got cascade_save on for the user's relationship to profile, and for the profile's relationship to departments. My edit user form has a multiselect for the departments but when I try to save I get a message saying "Invalid Model instance added to relations in this model."
In the edit action of Controller_Users I'm relating it by having...
Assuming "->departments" is the relation, you can not assign strings to it, you have to assign related model objects to it. For a has_one/belongs_to relation, that is a single object, for the others, it's an array of objects.
Again assuming this form returns a list of keys of selected departments, you'll have to fetch the existing departments, unset the ones not selected in the form, fetch the objects not already present in the relation, and add them, before saving.
god bless you i search and try for 10hours to find out why this happening.
thank you you are the first how tells someone what to do and not only write: "i solved it by my own..." and let the googlers in the dark xD (=hate this posts). love you for your comment dude! you saved my sleep :D
i updated your code little bit because it throws errors when i the parent model tries to add relation between an empty child model here you can find also the issue #283 on github