public function validateRelation($attribute, $params)
    {
        $relation = $this->getRelation($attribute);
        $attributes = isset($params['attributes']) ? $params['attributes'] : null;
        $errors = [];

        $models = $this->$attribute;
        if (!$relation->multiple) {
            $models = [$models];
        }
        /** @var \yii\db\ActiveRecord[] $models */
        foreach ($models as $index => $model) {
            if (isset($params['scenario'])) {
                $model->scenario = $params['scenario'];
            }

            if ($model->validate($attributes)) {
                continue;
            }
            $errors[] = (string)$model . ': ' . \yii\helpers\Html::errorSummary($model, ['header' => '']) ;
        }

        $this->populateRelation($attribute, $relation->multiple ? $models : $models[0]);
        if (empty($errors)) {
            return;
        }

        $errors = "<ul><li>" . implode("</li>\n<li>", $errors) . "</li></ul>";

        $placeholders = [
            'attribute' => $this->getRelationLabel($relation, $attribute),
        ];
        $message = $relation->multiple
            ? \Yii::t('app', '{attribute} have invalid items:', $placeholders)
            : \Yii::t('app', '{attribute} is invalid:', $placeholders);
        $this->addError($attribute, $message . $errors);
    }