2017-02-14 10 views
0

유효성 검사 중에 yii2에 힌트를 표시 할 수 있습니까? 내 모델 나는이 :Yii2 유효성 검사시 힌트 표시

public function rules() 
     { 
      return [ 
       [['content'], 'checkLastCommentDate', 'skipOnEmpty' => false, 'skipOnError' => false], 
      ]; 
     } 

    public function checkLastCommentDate($attribute) 
    { 
     if (true) { 
      //can set hint here? 
     } 
    } 

답변

0

는 모델 :: addError 방법을 사용하여 힌트 같은 뭔가를하지만 검증에 사용할 수 없습니다 yii2

public function checkLastCommentDate($attribute) 
{ 
    if (true) { 
     $this->addError($attribute, 'Here is my hint'); 
    } 
} 
+0

없음. 어쩌면 그것이 유효성 검증에 있어서는 안된다. $ vat == 5 인 경우에만 표시 힌트를 원합니다. –