src/Forms/TreeMultiselectField.php
public function getItems()
    {
        $items = new ArrayList();

        // If the value has been set, use that
        if ($this->value != 'unchanged') {
            $sourceObject = $this->getSourceObject();
            if (is_array($sourceObject)) {
                $values = is_array($this->value) ? $this->value : preg_split('/ *, */', trim($this->value));

                foreach ($values as $value) {
                    $item = new stdClass;
                    $item->ID = $value;
                    $item->Title = $sourceObject[$value];
                    $items->push($item);
                }
                return $items;
            }

            // Otherwise, look data up from the linked relation
            if (is_string($this->value)) {
                $ids = explode(',', $this->value);
                foreach ($ids as $id) {
                    if (!is_numeric($id)) {
                        continue;
                    }
                    $item = DataObject::get_by_id($sourceObject, $id);
                    if ($item) {
                        $items->push($item);
                    }
                }
                return $items;
            }
        }

        if ($this->form) {
            $fieldName = $this->name;
            $record = $this->form->getRecord();
            if (is_object($record) && $record->hasMethod($fieldName)) {
                return $record->$fieldName();
            }
        }

        return $items;
    }
public function getItems()
    {
        $items = new ArrayList();

        // If the value has been set, use that
        if ($this->value != 'unchanged') {
            $sourceObject = $this->getSourceObject();
            if (is_array($sourceObject)) {
                $values = is_array($this->value) ? $this->value : preg_split('/ *, */', trim($this->value));

                foreach ($values as $value) {
                    $item = new stdClass;
                    $item->ID = $value;
                    $item->Title = $sourceObject[$value];
                    $items->push($item);
                }
                return $items;
            }

            // Otherwise, look data up from the linked relation
            if (is_string($this->value)) {
                $ids = explode(',', $this->value);
                foreach ($ids as $id) {
                    if (!is_numeric($id)) {
                        continue;
                    }
                    $item = DataObject::get_by_id($sourceObject, $id);
                    if ($item) {
                        $items->push($item);
                    }
                }
                return $items;
            }
        }

        if ($this->form) {
            $fieldName = $this->name;
            $record = $this->form->getRecord();
            if (is_object($record) && $record->hasMethod($fieldName)) {
                return $record->$fieldName();
            }
        }

        return $items;
    }
public function getItems ( ) { $ items = new ArrayList ( ) ; // If the value has been set, use that if ( $ this -> value != 'unchanged' ) { $ sourceObject = $ this -> getSourceObject ( ) ; if ( is_array ( $ sourceObject ) ) { $ values = is_array ( $ this -> value ) ? $ this -> value : preg_split ( '/ *, */' , trim ( $ this -> value ) ) ; foreach ( $ values as $ value ) { $ item = new stdClass ; $ item -> ID = $ value ; $ item -> Title = $ sourceObject [ $ value ] ; $ items -> push ( $ item ) ; } return $ items ; } // Otherwise, look data up from the linked relation if ( is_string ( $ this -> value ) ) { $ ids = explode ( ',' , $ this -> value ) ; foreach ( $ ids as $ id ) { if ( ! is_numeric ( $ id ) ) { continue ; } $ item = DataObject :: get_by_id ( $ sourceObject , $ id ) ; if ( $ item ) { $ items -> push ( $ item ) ; } } return $ items ; } } if ( $ this -> form ) { $ fieldName = $ this -> name ; $ record = $ this -> form -> getRecord ( ) ; if ( is_object ( $ record ) && $ record -> hasMethod ( $ fieldName ) ) { return $ record -> $ fieldName ( ) ; } } return $ items ; }
Return this field's linked items
@return ArrayList|DataList $items
Return this field s linked items