Sivanthi
(Sivanthi071)
March 15, 2013, 10:23am
1
$form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id'=>'registration-register-form',
'htmlOptions'=>array('class'=>'well'),
'enableAjaxValidation'=>true,
'focus'=>array($model,'columname to focus'),
'enableClientValidation'=>true,
));
mdomba
(Maurizio Domba Cerin)
March 16, 2013, 8:54pm
2
By using
'focus'=>array($model,'columname to focus')
you need to add the right columnname for every form… a more general selector could be used here, like those suggested on the focus documentation - http://www.yiiframew …rm#focus-detail
To focus first input element of type text:
'focus'=>'input[type="text"]:first'
To focus first visible and enabled input element
'focus'=>'input:visible:enabled:first'
To focus first empty input
'focus'=>'input:text[value=""]:first'
Sivanthi
(Sivanthi071)
March 18, 2013, 5:32am
3
By using
'focus'=>array($model,'columname to focus')
you need to add the right columnname for every form… a more general selector could be used here, like those suggested on the focus documentation - http://www.yiiframew …rm#focus-detail
To focus first input element of type text:
'focus'=>'input[type="text"]:first'
To focus first visible and enabled input element
'focus'=>'input:visible:enabled:first'
To focus first empty input
'focus'=>'input:text[value=""]:first'
Thanks a lot for your information.
rajyii
(Yraj456789)
August 8, 2014, 5:48am
4
In advanced search this is not the case because by default form is hidden(display : none) in advanced search and field is focused, when we click advanced search link to show form (display :block) the field focus is gone.
so I tried this
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
$('input:text:visible:first').focus()
return false;
});