I have discovered perhaps abnormal behaviour with Akelos.
If ModelOne has a many-to-one association with ModelTwo and it is loaded in ModelOne (via load()), changing the relation through the id property of ModelOne i.e. $this->model_two_id = 10 will not be serialised to the database when calling save(). However if it hasn't been loaded the save will be fine.
In the first case (id change) the id of ModelTwo reverts back to the original id. However save() will return true in both instances. It appears that when modifying the id of the reference, the loaded model is not notified through an observer pattern.
If I wish to change ModelTwo in ModelOne I have to load the ModelTwo and pass that in to ModelOne: i.e. $this->model_two = $ModelTwo->find(10). This has the correct behaviour, however, there is the overhead of loading the ModelTwo even though I don't need it (I already know the ID by other means).
Kind regards,
John
CommentAuthorbermi
Associations work with callbacks, so if you don't load the association no callback will override your manually set id.