Hello everyone,
I'm trying to add a few fields to the Drupal login form. Using hook_form_alter I was able to change the login form to display a new field, but the new field appears at the bottom of the form. Here is the code I used to change the form:
$form[newfield] = Array ( '#type' => 'textfield', '#title' => 'newfield_title', '#maxlength' => 60, '#size' => 15, '#required' => 1, );
I get my new textfield, but I would like to place it after (below) the password field.
It is not apparent to me how the default layout is generated. When I examine the $form variable I don't see anything that would indicate an ordering of elements. Is this something that has to be done via .tpl file in theme? I would rather avoid that because then the login form becomes disordered again if I change themes. Please advise.
On Sat, Feb 21, 2009 at 11:42 PM, Michael Anderson usufruct@gmail.comwrote:
Hello everyone,
I'm trying to add a few fields to the Drupal login form.
You can do this using profile a core optional module.
[ Drupal support list | http://lists.drupal.org/ ]
Use the #weight property to assign order.
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html/5#w...
Steve
Michael Anderson wrote:
Hello everyone,
I'm trying to add a few fields to the Drupal login form. Using hook_form_alter I was able to change the login form to display a new field, but the new field appears at the bottom of the form. Here is the code I used to change the form:
$form[newfield] = Array ( '#type' => 'textfield', '#title' => 'newfield_title', '#maxlength' => 60, '#size' => 15, '#required' => 1, );I get my new textfield, but I would like to place it after (below) the password field.
It is not apparent to me how the default layout is generated. When I examine the $form variable I don't see anything that would indicate an ordering of elements. Is this something that has to be done via .tpl file in theme? I would rather avoid that because then the login form becomes disordered again if I change themes. Please advise.
-- La perfection est atteinte non quand il ne reste rien à ajouter, mais quand il ne reste rien à enlever. — Antoine de Saint-Exupéry
2009/2/21 Michael Anderson usufruct@gmail.com:
It is not apparent to me how the default layout is generated. When I examine the $form variable I don't see anything that would indicate an ordering of elements. Is this something that has to be done via .tpl file in theme? I would rather avoid that because then the login form becomes disordered again if I change themes. Please advise.
You need to look at 'weight' - http://api.drupal.org/api/file/developer/topics/forms_api_reference.html/6#weightval
Dan