src/Forms/MultiSelectField.php
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)) {
            // Load dataValue from field... a CSV for DBMultiEnum
            if ($record->obj($fieldName) instanceof DBMultiEnum) {
                $value = $this->csvDecode($record->$fieldName);

            // ... JSON-encoded string for other fields
            } else {
                $value = $this->stringDecode($record->$fieldName);
            }

            parent::setValue($value);
        }
    }
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)) {
            // Load dataValue from field... a CSV for DBMultiEnum
            if ($record->obj($fieldName) instanceof DBMultiEnum) {
                $value = $this->csvDecode($record->$fieldName);

            // ... JSON-encoded string for other fields
            } else {
                $value = $this->stringDecode($record->$fieldName);
            }

            parent::setValue($value);
        }
    }
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 ) ) { // Load dataValue from field... a CSV for DBMultiEnum if ( $ record -> obj ( $ fieldName ) instanceof DBMultiEnum ) { $ value = $ this -> csvDecode ( $ record -> $ fieldName ) ; // ... JSON-encoded string for other fields } else { $ value = $ this -> stringDecode ( $ record -> $ fieldName ) ; } parent :: setValue ( $ value ) ; } }
Load the value from the dataobject into this field

@param DataObject|DataObjectInterface $record
Load the value from the dataobject into this field