From: jamiesensei Date: Mon, 30 Oct 2006 06:27:15 +0000 (+0000) Subject: changed focus when there is no error in the page to the first element in a form rathe... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=5c52df6797f3f79ef140abd2cb9389e2f250e0b0;p=moodle.git changed focus when there is no error in the page to the first element in a form rather than no focus. --- diff --git a/lib/formslib.php b/lib/formslib.php index badc2c688e..af2ebda810 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -45,18 +45,19 @@ class moodleform { * To autofocus on first form element with error. * * @return string javascript to select form element with first error or - * '' if no errors. + * first element if no errors. */ function focus(){ $form=$this->_form; + $elkeys=array_keys($form->_elementIndex); if (isset($form->_errors) && 0!=count($form->_errors)){ $errorkeys=array_keys($form->_errors); - $elkeys=array_keys($form->_elementIndex); $keyinorder=array_intersect($elkeys, $errorkeys); $el='getElementById(\'id_'.array_shift($keyinorder).'\')'; return $el; } else{ - return ''; + $el='getElementById(\'id_'.array_shift($elkeys).'\')'; + return $el; } }