Hello There is a validation rule

array('email', 'unique', 'message'=>'This email already exists','on' => 'register'). 

The problem is that others when errors occur in other validators ( required,compare , etc.), the message in view is displayed on the screen, but with unique there is no response. Tell me how to properly set the output of this error in case of occurrence? Thank.

 $this->pageTitle = Yii::app()->name . ' - Registration'; ?> <div class="form"> <?php $form = $this->beginWidget('CActiveForm', array( 'id' => 'login-form', 'enableClientValidation' => true, 'clientOptions' => array( 'validateOnSubmit' => true, ), )); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <div class="row"> <?php echo $form->labelEx($model, 'username'); ?> <?php echo $form->textField($model, 'username'); ?> <?php echo $form->error($model, 'username'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'email'); ?> <?php echo $form->textField($model, 'email'); ?> <?php echo $form->error($model, 'email'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'password'); ?> <?php echo $form->passwordField($model, 'password'); ?> <?php echo $form->error($model, 'password'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'passwordConfirm'); ?> <?php echo $form->passwordField($model, 'passwordConfirm'); ?> <?php echo $form->error($model, 'passwordConfirm'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton('Registration'); ?> </div> <?php $this->endWidget(); ?> </div> 
  • Please complete the question. Show the view code. And what exactly do you want? Dynamic validation via ajax? Or normal server validation? - Makarenko_I_V
  • I just need that if an email matches what is entered in the form with an email from the database, a corresponding message is displayed that such email already exists. With or without Ajax - no difference - Roma Tulaydan
  • You are a programmer, you decide how it will be, it can not be without a difference! Or ask your customer. - Makarenko_I_V
  • I mean, this is irrelevant, we just need a normal output of the validator's unique) - Roma Tulaydan
  • Does a record with duplicate e-mail appear in the database? - Samuel Loog

0