public function validateParentContentElement($attribute) { if (!$this->cmsContent) { return false; } if (!$this->cmsContent->parentContent) { return false; } if ($this->{$attribute}) { $contentElement = static::findOne($this->{$attribute}); if ($contentElement->cmsContent->id != $this->cmsContent->parentContent->id) { $this->addError($attribute, \Yii::t('skeeks/cms', 'The parent must be a content element: «{contentName}».', ['contentName' => $this->cmsContent->parentContent->name])); } } }