original_string: function focus($name=NULL) {
          $form =& $this->_form;
          $elkeys = array_keys($form->_elementIndex);
          $error = false;
          if (isset($form->_errors) &&  0 != count($form->_errors)){
              $errorkeys = array_keys($form->_errors);
              $elkeys = array_intersect($elkeys, $errorkeys);
              $error = true;
          }
  
          if ($error or empty($name)) {
              $names = array();
              while (empty($names) and !empty($elkeys)) {
                  $el = array_shift($elkeys);
                  $names = $form->_getElNamesRecursive($el);
              }
              if (!empty($names)) {
                  $name = array_shift($names);
              }
          }
  
          $focus = '';
          if (!empty($name)) {
              $focus = 'forms[\''.$form->getAttribute('id').'\'].elements[\''.$name.'\']';
          }
  
          return $focus;
       }
code: function focus($name=NULL) {
          $form =& $this->_form;
          $elkeys = array_keys($form->_elementIndex);
          $error = false;
          if (isset($form->_errors) &&  0 != count($form->_errors)){
              $errorkeys = array_keys($form->_errors);
              $elkeys = array_intersect($elkeys, $errorkeys);
              $error = true;
          }
  
          if ($error or empty($name)) {
              $names = array();
              while (empty($names) and !empty($elkeys)) {
                  $el = array_shift($elkeys);
                  $names = $form->_getElNamesRecursive($el);
              }
              if (!empty($names)) {
                  $name = array_shift($names);
              }
          }
  
          $focus = '';
          if (!empty($name)) {
              $focus = 'forms[\''.$form->getAttribute('id').'\'].elements[\''.$name.'\']';
          }
  
          return $focus;
       }
code_tokens: function focus ( $ name = NULL ) { $ form = & $ this -> _form ; $ elkeys = array_keys ( $ form -> _elementIndex ) ; $ error = false ; if ( isset ( $ form -> _errors ) && 0 != count ( $ form -> _errors ) ) { $ errorkeys = array_keys ( $ form -> _errors ) ; $ elkeys = array_intersect ( $ elkeys , $ errorkeys ) ; $ error = true ; } if ( $ error or empty ( $ name ) ) { $ names = array ( ) ; while ( empty ( $ names ) and ! empty ( $ elkeys ) ) { $ el = array_shift ( $ elkeys ) ; $ names = $ form -> _getElNamesRecursive ( $ el ) ; } if ( ! empty ( $ names ) ) { $ name = array_shift ( $ names ) ; } } $ focus = '' ; if ( ! empty ( $ name ) ) { $ focus = 'forms[\'' . $ form -> getAttribute ( 'id' ) . '\'].elements[\'' . $ name . '\']' ; } return $ focus ; }
docstring: To autofocus on first form element or first element with error.
  
  @param string $name if this is set then the focus is forced to a field with this name
  @return string javascript to select form element with first error or
  first element if no errors. Use this as a parameter
  when calling print_header
docstring_tokens: To autofocus on first form element or first element with error .