Possible bug in updating field values from hasOne->addField

I’ve noticed something that I think may be a bug. I have a Model that gets some fields from another model. The other model defines certain parameters about that kind of model. The init function of Model ‘Thing’ looks something like:

$this->hasOne(‘thingType_id’, [new ThingType(), ‘required’ => true)->addFields([‘hasRed’, ‘hasBlue’]);

I’d like to allow the user to change a Thing to a new ThingType, but include validation based on the new fields. For the example above, let’s say that hasRed is a boolean. Assume that the Thing record initially is set to a ThingType where hasRed is true. Under certain conditions, I’d like to require that the ThingType be one where hasRed is true. I therefore have the following validation hook in Thing’s definition:

$this->addHook(‘validate’, function ($m) {
if (!$m[‘hasRed’]) return ([‘thingType_id’ => ‘You must choose a type with hasRed’]);

The problem I’m seeing is that when the user chooses a new ThingType in my form and hits save, my
validation routine is called – but the value of hasRed is the valid from the thingType_id from when the
record was loaded, not the one from the new thingType_id that the user choose. It appears that the values of the fields imported by hasOne->addField are only loaded on record load, not when the hasOne field changes. For the purposes of the validation routine, I can manually load the record for the new thingType_id and get around this issue, so there’s no big deal (but it’s awkward).

However, I’d also like to display the fields imported by hasOne->addField in my Thing form. I write the straightforward code to do so, and everything looks fine – until the user chooses a new thingType_id. The displayed values of hasRed and hasBlue remain unchanged. Unlike with the validation hook, I can’t think of a way around this.

Am I correct in saying that field values from hasOne->addFields are only updated on record load, and not prior to a save/reload? Should this be considered a bug? Is there a way for me to change the behavior to what I would consider expected, i.e., if $m->isDirty(‘thingType_id’) then all of the fields from the addField are reloaded based on the new thingType_id and considered dirty (or, if it’s real fancy, compares each those fields between the old and new thingType_id and only considers the changed ones dirty)?

Thanks for any thoughts you have on this.