T
T
tincap2015-07-11 16:32:58
Yii
tincap, 2015-07-11 16:32:58

How to use offline validation in Yii2?

Nowhere does it say how to use offline validation.
Let's say we created a standalone validator:

class SimpleValidator extends Validator {
    public function validateAttribute($model, $attribute) {
        $this->addError($model, $attribute, "Просто ошибка");
    }
}

How to use it now? What's next? How to specify this validator in the model so that it works?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Gogolinsky, 2015-07-11
@tincap

['my_field', SimpleValidator::className()]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question