reverserelations icon indicating copy to clipboard operation
reverserelations copied to clipboard

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

Open monachilada opened this issue 7 years ago • 0 comments

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.

monachilada avatar Jun 01 '17 08:06 monachilada