How to set validation message for field having ajax validation in scenarios? - Yii2
<p>I'm using one model file for 2 forms. One for <strong>SIGNUP</strong> &amp; Other for A<strong>dding members</strong>.</p>

<p>I didn't set any scenario for <strong>SIGNUP</strong> form. But, scenario for <strong>Adding members</strong> form is set.</p>

<p><strong>Model</strong></p>

<pre><code>public function rules() {
  return [

    //Add Members
    ['first_name', 'required','message'=&gt;'Please enter first name.','on'=&gt;'addteammembersidebar'],
    ['email', 'required','message'=&gt;'Please enter email address.','on'=&gt;'addteammembersidebar'],
    ['mobile','required','message'=&gt;'Please enter mobile number.','on'=&gt;'addteammembersidebar'],

    //Common
    ['first_name', 'required','message'=&gt;'Please enter your first name.'],
    ['email', 'required','message'=&gt;'Please enter your email address.'],
    ['mobile','required','message'=&gt;'Please enter your mobile number.'],

  ];
}
</code></pre>

<p><strong>View</strong></p>

<p>Here, I set scenario like <code>$modelTeamMembers-&gt;scenario = 'addteammembersidebar';</code>.</p>

<pre><code>&lt;?php foreach ($modelsTeamMembers as $indexMember =&gt; $modelTeamMembers): 
  $modelTeamMembers-&gt;scenario = 'addteammembersidebar';
  ?&gt;
  &lt;tr class="house-item"&gt;
    &lt;td class="vcenter"&gt;
      &lt;?php
      // necessary for update action.
      if (! $modelTeamMembers-&gt;isNewRecord) {
        echo Html::activeHiddenInput($modelTeamMembers, "[{$indexMember}]id");
      }
      ?&gt;

      &lt;?php 
      $modelTeamMembers-&gt;first_name = $first_name;
      echo $form-&gt;field($modelTeamMembers, "[{$indexMember}]first_name")-&gt;label(false); 
      ?&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;?php
      $modelTeamMembers-&gt;last_name = $last_name;
      echo $form-&gt;field($modelTeamMembers, "[{$indexMember}]last_name")-&gt;label(false); 
      ?&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;?php
      $modelTeamMembers-&gt;email = $email;
      echo $form-&gt;field($modelTeamMembers, "[{$indexMember}]email",['enableAjaxValidation' =&gt; true])-&gt;label(false); 
      ?&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;?php
      $modelTeamMembers-&gt;mobile = $mobile_number;
      echo $form-&gt;field($modelTeamMembers, "[{$indexMember}]mobile",
          ['inputOptions' =&gt; ['class' =&gt; 'form-control', 'maxlength'=&gt;"10"]])-&gt;label(false);
      ?&gt;
    &lt;/td&gt;
  &lt;/tr&gt;

&lt;?php endforeach; ?&gt;
</code></pre>

<p>All validation error message working except for <code>email</code> field. If, I remove <code>'enableAjaxValidation' =&gt; true</code> from field, it works. But, for me <code>'enableAjaxValidation' =&gt; true</code> is required.</p>

<p><strong>Image</strong></p>

<p><a href="https://i.stack.imgur.com/sanfp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sanfp.png" alt="enter image description here"></a></p>

<p>As in image, it is clearly visible that error message coming "<em>Please enter your email address.</em>" Which should be "<em>Please enter email address.</em>". Only <code>email</code> field validation error message not coming correct. Except all are fine.</p>

<p>How to set validation message for <code>email</code> field for scenarios? Any help/hint/suggestions are appreciable.</p>