Hi,
Has anybody come up with a solution to focus on the first field on initial page load and then on the first error after validation fails?
<?php
$form = $this->beginWidget('CActiveForm', array(
'htmlOptions' => array(
'enctype' => 'multipart/form-data',
),
'focus'=>'.error:first',
));
?>
Cheers,
Matt
I think this should work in most cases.
$form = $this->beginWidget('CActiveForm', array(
'htmlOptions' => array(
'enctype' => 'multipart/form-data',
),
'focus'=>($model->hasErrors()) ? '.error:first' : array($model, 'title'),
'enableClientValidation' => true,
));
Cheers,
Matt
hi friends you can use
<?php $form=$this->beginWidget(‘CActiveForm’, array(
'id'=>'login-form',
//'action'=> Yii::app()->createUrl( '/user/login'),
'enableClientValidation'=>true,
'focus'=>array($model,'username'),
'clientOptions'=>array(
'validateOnSubmit'=>true,
),
)); ?>
it works fine for me…