Focus on 1st field and on 1 error

Hi,

This should focus the input to the 1st field on initial page load and then on the 1st error after validation.


$form = $this->beginWidget('CActiveForm', array(

            'htmlOptions' => array(

                'enctype' => 'multipart/form-data',

            ),

            'focus'=>($model->hasErrors()) ? '.error:first' : array($model, 'title'),

            'enableClientValidation' => true,

        ));

Cheers,

Matt