php - Validating multiple attributes within a inline validator in Yii 2 -


i'm aware can validate single attribute using inline validator such as:

['country', 'validatecountry']  public function validatecountry($attribute, $params) {     if (!in_array($this->$attribute, ['usa', 'web'])) {         $this->adderror($attribute, 'the country must either "usa" or "web".');     } } 

but how go passing in multiple attributes validator? ...or should reference them via $this within validator?

instead of accessing fields directly e.g using $this->email pass additional attributes field in params, how comparevalidator works i.e

['username', 'customvalidator', 'params' => ['extrafields' => 'email']]   public function customvalidator($attribute, $params) {     //access extrafields using $this->{$params['extrafields']} } 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -