[[+content_image]]
M
M
Mikha Pankratov2015-12-22 11:04:04
Yii
Mikha Pankratov, 2015-12-22 11:04:04

Why is eachValidator not working?

Good afternoon,
Tell me about EachValidator in yii2.
I don’t understand how I can pass an array of my values ​​\u200b\u200bto it?
Model

public function rules() {
    return [
        [['field'], 'each', 'in', 'range' => array_keys(static::getAttributes(['field']))]
    ];
  }

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
V
Vladimir Korovin, 2015-12-22
@frmax

3rd parameter of this rule "rule" - defines the validation rules, i.e.:

[['field'], 'each', 'rule' => ['in', 'range' => array_keys(static::getAttributes(['field']))]]

T
Talgat Baltasov, 2015-12-22
@talgatbaltasov

https://github.com/yiisoft/yii2/blob/master/docs/g...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question