boboldehampsink / reverserelations

DEPRECATED - Reverse Relations Plugin for Craft CMS
MIT License
16 stars 3 forks source link

Saving reverse relations fails when the target element has required fields. #12

Open monachilada opened 7 years ago

monachilada commented 7 years ago

Trying to reverse save relations from the target element of a relation, I can add the desired elements to the field and then save the element, but when the edit page reloads the connections aren't there. Doing some digging in the onAfterElementSave() function, I debugged $target->getErrors() to see that one those target elements, because some required fields weren't being specifically set before saving, that the save would field.

I've run into this problem before and the only solution I've found is to loop through all the fields on the element, figure out which are required, then explicitly add those values before attempting to save. It feels like there should be a simpler way around this, and maybe you know one.