I'm noticing that there's a PHP-based API for has_many and many_many relations, but I'm not seeing any documentation covering an API for has_one relations, e.g. take a polymorphic has_one for example:
// Where "tag" could also be any other DataObject which points back to "Story.Polymorphic"
$tag = Tag::create();
$tag->Title = 'Test Tag';
$tag->write();
$story->Polymorphic = $tag
$story->write();
Intuitively, this is how I'd write it, but it doesn't seem to work for me. In this example, TagID and TagClass remain 0 and null respectively. Is there some other magic to this or do I really need to edit those fields directly? Just curious since I'm not sure how else I'd implement this in the CMS anyway (albeit my use case may still require more direct access like $story->relation()->add(...) anyway instead of some pre-built FormField).
Any ideas? Is there a better way?