yii2: Each validator doesn't show error messages below input field instantly

When I have many fields with the same attribute and I use the “each” validator in model as for example:

<?php
// Using ActiveForm by widget package and bootstrap package ...

// ...
['name', 'each', 'rule' => ['required']],
// ...

… the input doesn’t shows an instantly error with a message saying that must be a “required input”, same that you do use other validator type. When you don’t use the each validator and use only the required validator, the error message is visible below input field.

<?php
// Using ActiveForm by widget package and bootstrap package ...

// ...
['name', 'each', 'rule' => ['required']], // It doesn't shows the instantly error message below input field
['name', 'required'], // It does shows the instantly error message below input field
// ...

How can I solve this problem?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

captura de tela de 2015-09-01 07-04-58

@lynicidn It’s what I want to say. You see it showing an error when, for example, I put an invalid email. But, when I don’t use in model:

['email', 'email'],

But …

['email', 'each', 'rule' => ['email']],

It doesn’t shows that errors instantly. Did you understand now?