コード例 #1
0
 /**
  * Load the value from the dataobject into this field
  *
  * @param 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);
     }
 }