protected function setMultipleRelation($relationName, $value)
    {
        /** @var BaseActiveRecord $owner */
        $owner = $this->owner;
        /** @var ActiveQuery $relation */
        $relation = $owner->getRelation($relationName);
        $newRelations = [];
        if (!is_array($value)) {
            if (!empty($value)) {
                $value = [$value];
            } else {
                $value = [];
            }
        }
        foreach ($value as $entry) {
            if ($entry instanceof $relation->modelClass) {
                $newRelations[] = $entry;
            } else {
                // TODO handle this with one DB request to retrieve all models
                $newRelations[] = $this->processModelAsArray($entry, $relation, $relationName);
            }
        }
        $this->_newRelationValue[$relationName] = $newRelations;
        $owner->populateRelation($relationName, $newRelations);
    }
protected function setMultipleRelation($relationName, $value)
    {
        /** @var BaseActiveRecord $owner */
        $owner = $this->owner;
        /** @var ActiveQuery $relation */
        $relation = $owner->getRelation($relationName);
        $newRelations = [];
        if (!is_array($value)) {
            if (!empty($value)) {
                $value = [$value];
            } else {
                $value = [];
            }
        }
        foreach ($value as $entry) {
            if ($entry instanceof $relation->modelClass) {
                $newRelations[] = $entry;
            } else {
                // TODO handle this with one DB request to retrieve all models
                $newRelations[] = $this->processModelAsArray($entry, $relation, $relationName);
            }
        }
        $this->_newRelationValue[$relationName] = $newRelations;
        $owner->populateRelation($relationName, $newRelations);
    }
protected function setMultipleRelation ( $ relationName , $ value ) { /** @var BaseActiveRecord $owner */ $ owner = $ this -> owner ; /** @var ActiveQuery $relation */ $ relation = $ owner -> getRelation ( $ relationName ) ; $ newRelations = [ ] ; if ( ! is_array ( $ value ) ) { if ( ! empty ( $ value ) ) { $ value = [ $ value ] ; } else { $ value = [ ] ; } } foreach ( $ value as $ entry ) { if ( $ entry instanceof $ relation -> modelClass ) { $ newRelations [ ] = $ entry ; } else { // TODO handle this with one DB request to retrieve all models $ newRelations [ ] = $ this -> processModelAsArray ( $ entry , $ relation , $ relationName ) ; } } $ this -> _newRelationValue [ $ relationName ] = $ newRelations ; $ owner -> populateRelation ( $ relationName , $ newRelations ) ; }
Set the named multiple relation with the given value
@param string $relationName
@param $value
@throws \yii\base\InvalidArgumentException
Set the named multiple relation with the given value