common/models/hierarchy/HierarchicalModel.php
public function validateParentChain( $attribute, $params ) {

		if( !$this->hasErrors() ) {

			if( isset( $this->parentId ) && $this->parentId > 0 && $this->parentId == $this->id ) {

				$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_PARENT_CHAIN ) );
			}
		}
	}
public function validateParentChain( $attribute, $params ) {

		if( !$this->hasErrors() ) {

			if( isset( $this->parentId ) && $this->parentId > 0 && $this->parentId == $this->id ) {

				$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_PARENT_CHAIN ) );
			}
		}
	}
public function validateParentChain ( $ attribute , $ params ) { if ( ! $ this -> hasErrors ( ) ) { if ( isset ( $ this -> parentId ) && $ this -> parentId > 0 && $ this -> parentId == $ this -> id ) { $ this -> addError ( $ attribute , Yii :: $ app -> coreMessage -> getMessage ( CoreGlobal :: ERROR_PARENT_CHAIN ) ) ; } } }
Validates parent to ensure that the model cannot be parent of itself.

@param type $attribute
@param type $params
@return void
Validates parent to ensure that the model cannot be parent of itself .