yii components - How can I display a warning message on textfield in Yii -


i'm new yii framework , need display validation error message in login form "username cannot blank". now, have text field updated fields , during validation want message displayed. how can this?

controller

public function actionupdate($id)     {         $model = $this->loadmodel($id);      // set parameters bizrule     $params = array('groupzsupport'=>$model);     // check bizrule user     if (!yii::app()->user->checkaccess('updateself', $params) &&         !yii::app()->user->checkaccess('admin'))     {         throw new chttpexception(403, 'you not authorized perform action');     }       else     {         if(isset($_post['groupzsupport']))         {                                     $password_current=$_post['groupzsupport']['password_current'];               $pass=$model->validatepassword($password_current);              $model->attributes=$_post['groupzsupport'];                         if($pass==1)                         {                         $model->password = $model->hashpassword($_post['groupzsupport']['password_new']);             if($model->save())                 $this->redirect(array('/messagetemplate/admin'));                         }                         else {$errors="incorrect current password"; print '<span style="color:red"><b>'; print '</b><b>'.$errors; print '</b></span>';}         }          $this->render('update',array(             'model'=>$model,         ));     }     } 

view

<div class="form"> <?php $form=$this->beginwidget('cactiveform', array(     'id'=>'password-recovery-reset-password-form',     'enableajaxvalidation'=>false, )); ?>       <div class="row"><?php          echo $form->labelex($model,'username');          echo $form->textfield($model,'username',array('size'=>45,'maxlength'=>150));          echo $form->error($model,'username');      ?></div>   <div class="row">         <?php echo $form->labelex($model,'current password'); ?>         <?php echo $form->passwordfield($model,'password_current',array('size'=>30,'maxlength'=>30)); ?>         <?php echo $form->error($model,'password_current'); ?>     </div>          <div class="row">         <?php echo $form->labelex($model,'new password'); ?>         <?php echo $form->textfield($model,'password_new',array('size'=>30,'maxlength'=>30)); ?>         <?php echo $form->error($model,'password_new'); ?>     </div>          <div class="row">         <?php echo $form->labelex($model,'confirm new password'); ?>         <?php echo $form->passwordfield($model,'password_repeat',array('size'=>30,'maxlength'=>30)); ?>         <?php echo $form->error($model,'password_repeat'); ?>     </div>       <div class="row buttons"><?php          echo chtml::submitbutton('reset password');         ?></div><?php  $this->endwidget(); ?> </div> 

now i'm displaying @ top. enter image description here

i want display right on textfield in login page. enter image description here how can this?

before redirect, add message desired field.

in model validator:

$this->adderror('field_name', "message error.");

or in controller action:

$model->adderror('field_name', "message error.");


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -