I'd love to be able to focus on a textarea if that's the first element in my form.
I peeked in the code and see it is only looking for 'input'.
$jquery_snippet = '$(document).ready(function(){$("#'. $form['#id'] . ' input").not("[@type=\'hidden\']")[0].focus()});';
Now, what a great time for me to start learning more about jquery, but I thought I'd throw this out there in case you can do it in your sleep.
Comments
Comment #1
calebtr commentedI thought about this some more, and I realized the jQuery snippet is looking for the first item in an array of inputs, so a textarea wouldn't be included.
Instead of having jQuery figure out which field to focus on, why not have Drupal pick the field by seeing which textarea or input comes first? I poked around and saw that drupal uses this code to sort forms drupal_render:
I toyed around but wasn't able to add a quick fix.
Comment #2
anders.fajerson commentedFixed in 6.x: http://drupal.org/cvs?commit=326010
Comment #3
calebtr commentedWorks great - thanks!