I am setting up a script to automatically populate a schedule with only existing programs on a schedule each week. I've got the code down for everything except associating the image file (hosted on our servers) with the dataobject created for the series. The image is related to the dataobject via a has_one relation. I tried using the dataobject->setField() function using the name of the has_one relation as the field, but that did not work. What should I use to associate the image file with the dataobject?
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
//private static $has_one = ['MyImage' => 'Image'];
$dataObject->MyImageID = $image->ID;
$dataObject->write();