$set Not working when using with a relationship
I have an Organisation Resource, an Organisation has one Location which is a mophOne relationship. With the code below I make it possible for the user to input just the postal_code and the number, I have an API which fetches the address based on those two fields. When the result get's back I fill the other fields with the
Why isn't this working? How do I make this work?
$set() function as you can see. All of this works fine, the fields do get populated with the fetched data. But as soon as I press the save button on my resource, only the postal_code and the number get updated the other values reset to their original value before the $set happened ending up with an incorrect record in the database with the updated postal_code and number and the outdated street, city, province etc.Why isn't this working? How do I make this work?
Solution
I have found the bug. The fields that get set with the $set function are disabled, somehow this prevents them from being updated... This is strange behavior, I want the api to populate those fields and don't want them to be changed by the user.