If you have the following:

  • LoginToboggan enabled
  • Profile module enabled
  • At least one profile field set to show on registration form
  • LoginToboggan set to show both a e-mail address confirmation field and the password fields on the registration form

The result is that instead of the form fields looking like:

username
email
confirm email
password
confirm password

they now become:

username
email
password
confirm email
confirm password

which is of course highly confusing. :P

I spent the better part of an hour trying to figure out the "root" of why it does this and failed... in the end though this simple patch to just increase the weight of the password fields seems to fix the problem just fine.

Comments

webchick’s picture

Status: Needs review » Needs work

Bah, no. :P That's cheesy and it also doesn't work. :P

webchick’s picture

Title: LT + profile module can cause wrong order of registration fields » LT + hook_user op register causes wrong order of registration fields
StatusFileSize
new1.06 KB

Actually no. I don't see another way to fix this other than hard-coding the field weights. I threw a print_r($form) on line 186 of logintoboggan.module (at the end of the user_register form ID check).

Here's the output with no extra things on the registration form:

Array(
  ...
    [name] => Array
        (
            [#type] => textfield
            [#title] => Username
...
    [mail] => Array
        (
            [#type] => textfield
            [#title] => E-mail address
... (lots more here.. #validate, #submit, etc.)
    [conf_mail] => Array
        (
            [#type] => textfield
            [#title] => Confirm e-mail address
...
    [pass] => Array
        (
            [#type] => password
            [#title] => Password
...
    [conf_pass] => Array
        (
            [#type] => password
            [#title] => Confirm Password
...

Then here's the output when there's stuff added:

Array
(
...
    [account] => Array
        (
            [#type] => fieldset
            [#title] => Account information
            [name] => Array
                (
                    [#type] => textfield
                    [#title] => Username
...
            [mail] => Array
                (
                    [#type] => textfield
                    [#title] => E-mail address
...
            [pass] => Array
                (
                    [#type] => password
                    [#title] => Password
...
            [conf_mail] => Array
                (
                    [#type] => textfield
                    [#title] => Confirm e-mail address
...
            [conf_pass] => Array
                (
                    [#type] => password
                    [#title] => Confirm Password

I have NO idea why it's doing this! LT has the following code which allows for this test case and is putting the fields in the correct order:

        // Have to put these in the login form group if it's been created
        if (isset($form['account'])) {
          $form['account']['conf_mail'] = $form['conf_mail'];
          $form['account']['pass'] = $form['pass'];
          $form['account']['conf_pass'] = $form['conf_pass'];
          unset($form['conf_mail']);
          unset($form['pass']);
          unset($form['conf_pass']);
        }

(my print_r is right after this block -- there's nothing else that can be interfering)

So unless anyone has any better ideas, I'm going with the weight fix. :P This patch is a bit more robust than my other one, in that it should ensure these fields show up in order, regardless of other modules that may be injecting fields into this form in their own hook_form_alters. It's still kind of a cheesy fix, but I honestly don't know what else to do.

webchick’s picture

Status: Needs work » Needs review
webchick’s picture

Status: Needs review » Needs work

Nearing the point of wanting to scream now. ;) So that patch fixes it on my localhost running PHP 5 but not on my work server running PHP 4. *sigh* Will see what else I can come up with...

webchick’s picture

Status: Needs work » Needs review
StatusFileSize
new969 bytes

OKAY. hehe. Let's try this. Seems to work in both places, and no cheesy weight crap. No idea why the "normal" way won't work, but whatever.

webchick’s picture

Status: Needs review » Needs work

Nooooooooooooooooooooooooooooooooooooo!

Now the ressinfressin validation doesn't pass. :(

webchick’s picture

Must be another blankety-blanking difference between PHP 5 and PHP 4... PHP 5 correctly inserts $form['account']['mail_conf'], etc. PHP 4 inserts it as $form['account'][0]. SIGH. >:\

webchick’s picture

StatusFileSize
new983 bytes

Ok, I officially give up. Here's a weight patch I tested and works on both servers. Maybe someone smarter than me can come in and figure out what I'm overlooking later, but for now this works.

webchick’s picture

Status: Needs work » Needs review
hunmonk’s picture

Title: LT + hook_user op register causes wrong order of registration fields » bad ordering of user registration fields when account fieldset is used
Assigned: webchick » hunmonk
Status: Needs review » Fixed

phew. tough problem. turns out that when the account fieldset is used, even for a non-admin registration, there's a form field 'pass' that's set to null, so LT isn't actually inserting it's pass field fresh, but overwriting the already existing one, which results in the wacky ordering. i patched 4.7 and HEAD to specifically unset the account pass form field in this case, which corrects the problem...

desm0n’s picture

Did you say CVS and 4.7 was patched for this ? As i just downloaded both, overwritten the files and this problem still shows for me. Is there anything else i need to do to update ?

hunmonk’s picture

i tested the fix against latest HEAD on my local server, and it worked just fine. are you sure you have the latest files from CVS? if you downloaded the tarballs they are probably not the most current--they tend to lag a day or so behind...

desm0n’s picture

Ah i've never understood HEAD till today :) So i browse to the CVS http://cvs.drupal.org/viewcvs/drupal/contributions/modules/logintoboggan... and just download logintoboggan.module right ?

I always thought HEAD was the CVS tarball. See you live and learn :)

hunmonk’s picture

i would read this: http://drupal.org/repos

and try to get a CVS installation working for yourself. you'll find it indispensable once you have it working... :)

Anonymous’s picture

Status: Fixed » Closed (fixed)