You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
saveInto:317 calls setByIDList which deletes relationships which no longer exist, however saveInto is called before validate() is called on the model, so relationships are removed before validation can fail e.g. due to the lack of relationships. Similarly relationships are created before validate() is called on the model which leads to other problems e.g. if only a certain number of relationships are allowed. I would think that saveInto shoud be side-effect free as far as relationships go and the relationships should be made/broken on equivalent of an 'onAfterWrite' handler, but not sure where to add this in for a FormField.
The text was updated successfully, but these errors were encountered:
wakes
changed the title
saveInto updates relationships before validate is called
saveInto updates relationships before model's validate is called
Mar 31, 2016
The problem is that there is no way to "prepare" a write to a relationship in such a way that a failed validate() is able to prevent it, except for the case when using UnsavedRelation (which is only for records that have no saved relations at all).
I would think that saveInto should be side-effect free as far as relationships go
I suspect this would be very, very hard to do with the current framework API. :D
It might be easier to just veto DataObject::validate() from being able to validate relationships (other than has_one).
saveInto:317 calls setByIDList which deletes relationships which no longer exist, however saveInto is called before validate() is called on the model, so relationships are removed before validation can fail e.g. due to the lack of relationships. Similarly relationships are created before validate() is called on the model which leads to other problems e.g. if only a certain number of relationships are allowed. I would think that saveInto shoud be side-effect free as far as relationships go and the relationships should be made/broken on equivalent of an 'onAfterWrite' handler, but not sure where to add this in for a FormField.
The text was updated successfully, but these errors were encountered: