Form prefill does not work when redirecting to registration
taroza - February 1, 2009 - 18:20
| Project: | OpenID |
| Version: | HEAD |
| Component: | OpenID Client |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
Steps to reproduce in Drupal 6.9:
- Try to authenticate with an OpenID (assuming there is no user with this id)
- Fill some illegal data, so that autoregistration fails
- The registration form is displayed, but no data is prefilled
As far as my research goes the problem is in openid.module function openid_form_alter (line 117). The code is:
elseif ($form_id == 'user_register' && isset($_SESSION['openid'])) {
// We were unable to auto-register a new user. Prefill the registration
// form with the values we have.
$form['name']['#default_value'] = $_SESSION['openid']['values']['name'];
$form['mail']['#default_value'] = $_SESSION['openid']['values']['mail'];
// If user_email_verification is off, hide the password field and just fill
// with random password to avoid confusion.
if (!variable_get('user_email_verification', TRUE)) {
$form['pass']['#type'] = 'hidden';
$form['pass']['#value'] = user_password();
}
$form['auth_openid'] = array('#type' => 'hidden', '#value' => $_SESSION['openid']['values']['auth_openid']);
}The values for the form should be set using $form['account']['name'] for instance, and not $form['name'].
