/**
  * Load the value from the dataobject into this field
  *
  * @param DataObject|DataObjectInterface $record
  */
 public function loadFrom(DataObjectInterface $record)
 {
     $fieldName = $this->getName();
     if (empty($fieldName) || empty($record)) {
         return;
     }
     $relation = $record->hasMethod($fieldName) ? $record->{$fieldName}() : null;
     // Detect DB relation or field
     if ($relation instanceof Relation) {
         // Load ids from relation
         $value = array_values($relation->getIDList());
         parent::setValue($value);
     } elseif ($record->hasField($fieldName)) {
         $value = $this->stringDecode($record->{$fieldName});
         parent::setValue($value);
     }
 }
 public function castedCopy($classOrCopy)
 {
     $field = parent::castedCopy($classOrCopy);
     if ($field instanceof SingleSelectField && $this->getHasEmptyDefault()) {
         $field->setEmptyString($this->getEmptyString());
     }
     return $field;
 }