$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 $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?

Section::make('Adresgegevens')
->collapsible()
->columns(2)
->relationship('location')
->afterStateUpdated(function (?array $state, ?array $old, Set $set) {
    if ($state['country_code'] !== 'NL') {
        return;
    }

    if ($state['postal_code'] === $old['postal_code']
        && $state['number']   === $old['number']) {
        return;
    }

    $locationData = LocationData::from([
        'postal_code' => $state['postal_code'],
        'number'      => $state['number'],
        'addition'    => $state['addition'],
    ])->updateUsingAPI()->toArray();

    $set('location.street', $locationData['street'] ?? null);
    $set('location.city', $locationData['city'] ?? null);
    $set('location.municipality', $locationData['municipality'] ?? null);
    $set('location.province', $locationData['province'] ?? null);
    $set('location.lat', $locationData['lat'].'' ?? null);
    $set('location.long', $locationData['long'].'' ?? null);
})
->schema([
  ...
])
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.
Was this page helpful?