as can be seen in the form definition of user_register, $form['account'] is unset and form items moved to into the main part of the form, so in the form_alter of this module ends up adding a misleading $form['account'] (which confuses other modules that check if form['account'] is set)

CommentFileSizeAuthor
account_form.patch1.03 KBhefox

Comments

jaypan’s picture

Status: Active » Closed (won't fix)

You can use hook_form_alter() to adjust it however you would like. That's the advantage of hook_form_alter().

hefox’s picture

Status: Closed (won't fix) » Needs review

I am using hook_form_alter and weights to get around this bug, but this is a bug, and causing conflicts with contrib modules, which will be a problems for those that don't know what is happening or how to fix it.

Please, take a look at user_register, http://api.drupal.org/api/function/user_register/6, particularly

  // Remove form_group around default fields if there are no other groups.
  if (!$extra) {
    foreach (array('name', 'mail', 'pass', 'status', 'roles', 'notify') as $key) {
      if (isset($form['account'][$key])) {
        $form[$key] = $form['account'][$key];
      }
    }
    unset($form['account']);
  }

If the user_register form doesn't have an $extras returned, user_register form definations moves everything into main $form, getting rid of $form['account']. So when your form_alter adds in weights to $form['account'] despite it not existing, it creates this weight $form['account'] that basically looks like

$form = array(
  'account' => array(
   'name' => ('#weight' => whatever)
  ),
 'name' => array(
  // real name as moved here in user_register
  )
);

This causes problems when other modules that are correctly testing where $form['account'] exists, they see the false $form['account'] and end up changing that instead of the real values in the form, making those modules not work in some case (ie like email_registration module).

dave reid’s picture

Status: Needs review » Reviewed & tested by the community

Exactly what hefox explains.

jaypan’s picture

I'll look at this a little closer. At a quick glance at his explanation, it makes sense.

jaypan’s picture

Status: Reviewed & tested by the community » Fixed

Hefox - I've included this code in version 3.1. Thank you - it was a nice clean fix. I apologize for not looking at it a little closer when you first submitted it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.