When creating a new user in Firefox, selecting a role for the user submits the form, as if the you clicked the "Create New Account" button. It saves properly, it's just annoying that you can't select more than one role before it automatically submits. Which role is selected makes no difference.
This didn't happen yesterday, I don't know what I did to cause it. I have not added any new modules or themes or changed any stylesheets. It only happens in Firefox, not IE.
I am having a problem with the "Contact" and "Edit" tabs not appearing at the top of the profile page (separate issue - not looking for answers to this now), consequently I did try disabling both Profile Role and Profile modules. That didn't make any difference and I re-enabled them, first Profile, save, then Profile Role, save.
I tried editing user-profile.tpl.php as well, but ended up reverting to my original version that worked properly, so that shouldn't have caused any problems.
I have cleaned the cache out under Site Config > Performance, but that didn't fix it.
I changed the theme to Garland and it continued to do the same thing, submitting upon selecting a Role checkbox.
Editing a user's roles after the account has been created does not have the same bug, you can select as many roles as you want without it submitting. I searched the forums and Google but can't find anyone else that has this problem. Any ideas?
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | profile_role-onchange_submit-716158-13.patch | 1.37 KB | stewart.adam |
| #12 | onchange_submit_toggle_and_hook.patch | 2.61 KB | gooddesignusa |
| #11 | 716158-profile_role-select-role-forces-browser-submit.patch | 475 bytes | izmeez |
Comments
Comment #1
cindyr commentedThis is not a Firefox only bug, it happens in IE 7 as well. It seems to take IE a little longer to realize that I checked the box in IE, but it does happen there as well. I tried it once clicking the "Notify new user by email" box first, and then clicking the role, and it did NOT automatically submit the form. Any ideas what's going on, and why the roles are causing it to automatically submit?
Comment #2
cindyr commentedChanging the title to more accurately reflect this bug. Is no one else having this problem?
Comment #3
cindyr commentedLooking at the code on /admin/user/user/create, there is an onchange=submit() in each role after authenticated user:
Trying to track down why this is being inserted. I looked through the release notes for Drupal 6.15 and 6.16, it doesn't look like this was addressed in either release. Can't figure out why this is my problem and no one else's, unless it's a theme issue...
Comment #4
paraschkevov commentedHi cindyr,
this issue has indeed something to do with the profile_role module. As you can see on line 103 in the profile_role.module file the following code is being added to the register form:
$form['account']['roles']['#attributes']['onchange'] = 'submit()';Possible solution: You can directly comment it out in the profile_role.module file or try to alter the register form in one of your own modules, in order to remove this assignment.
Cheers,
Martin
Comment #5
cindyr commentedThanks so much! I can comment it out, seems like this would be a rather significant issue for someone though. I'll re-submit this on the profile_role module page. Thanks again for helping me figure out where this bug came from, you've helped me tremendously.
Cindy
Comment #6
cindyr commentedClosing here - it's a Profile Role issue.
Comment #7
aklump commentedHere's the snippet I used in a custom module hook_form_alter to get around this:
Comment #8
izmeez commentedJust came across this issue related to profile_role module
I have changed the settings of this issue to the correct module and marked it as active. Hope no one minds.
Comment #9
cdesautels commentedI had the same problem with this in v.1.3. The fix by aklump works fine. But I have to ask why is this even in the profile module?
Comment #10
izmeez commented@cdesautels Based on comment #4 it suggests the problem is an extra line in the profile_role.module and commenting out line 103 worked for me.
Comment #11
izmeez commentedI've rolled a patch based on comment #4. Hopefully someone can review it.
Comment #12
gooddesignusa commentedI created a patch that allows the toggling of this option. A checkbox to turn onchange_submit on or off is located @ /admin/user/profile/role.
The default option is for onchange_submit to be off.
In this patch I also included a hook that now allows other modules to alter the $roles var in the profile_role_form_user_register_alter function.
I needed this because I was creating a couple admin pages to create a specific user with certain roles. These roles had certain profile fields attached to them. Without this hook I would have to modify this module to show those profile fields on these admin user create pages.
The patch on http://drupal.org/node/431454 (Integrate with autoassignrole module) did just that. If this hook was around before that issue, autoassignrole would have been able to add the patch code to the autoassignrole module instead of having to patch profile_roles.
While creating my custom admin user create pages I noticed an issue. When my custom function would return $roles the key on the array would start @ 0. Changing array_key_exists to in_array inside the foreach in the profile_role_form_user_register_alter function fixed it.
The reason I did this was because our client had a simple blog website with 2 types of users. Editors and users who can only comment.
Instead of having to explain roles to the admin of the site I just created 2 user create pages that set the roles for them. On the comment only accounts we use first name and last name fields to generate the username with realname_registration. So on that user create page I show the 2 profile fields and hide the username. Seems like autoassignrole might have something like this in the future: http://drupal.org/node/971540 (Have paths for admin user creation by role)
If anyone is interested in the custom user create pages find me on irc.
Comment #13
stewart.adam commentedThis patch should be split into two issues: this one for the submit problem and #431454: Integrate with autoassignrole module regarding the role hook.
Credit for attached patch goes entirely to gooddesignusa, it is his fix from #12 but I have removed the bits relating to the autoassignrole problem and rebased it against 1.x-dev.
I tested his fix and it functions correctly, so I'm marking this as RTBC.
Comment #14
izmeez commented@stewart.adam, re: patch in #13 are you using the default = enabled (TRUE) to replicate the current behaviour?
Although some uses cases, such as admin creating user with multiple roles may need to disable onchange_submit.
Comment #15
stewart.adam commentedYes, I defaulted it to enabled to maintain the current behaviour (as little disruption as possible introduced by the update). As you mentioned some users don't like the feature so they could easily disable it via that checkbox.
Comment #16
izmeez commentedThanks, I can also confirm reviewing and testing the patch in #13.
Comment #17
David Stosik commentedHello,
That's a long shot, but maybe I'll get answers here.
I'm maintaining a quite old site which uses this module, and found this bug.
I don't really get what's the purpose of the module, but I get one thing: profile_role_form_user_register_alter() function alters user registration form. This is not the user edition form, so this "submit form on role checkbox change" behavior is only applied to new user form, whether it is the register form displayed to a new user (who, as far as I know, is not asked for which role to get), or for the create new user form in administration section, which obviously fails (that's the point of this issue, right?).
So, could someone please help me understand WHEN is this useful and makes sense?
Adding a checkbox "Enable auto-submit on change of role" may make sense on some (unknown to me cases), but it's not the way to go on the user registration form or the create new user admin form. Both those form should just not get this feature.
(...) (ellipsis)
OK, so, before submitting I had a look again, found something talking about "autoassignrole" module a few comments above. I reckon this modules may allow users to automatically choose their roles?
Wouldn't it be appropriate to set the "submit form on role checkbox change" behavior only when
- autoassignroles module is enabled
AND
- form is not "create new user" form
?
Just my two cents, and a lots of questions, hoping to understand this a little more.
Thanks,
David
Comment #18
stewart.adam commentedDavid, 'needs work' should only be used if you can find a bug or problem in the patch - please see Status settings for an issue for more information.
The patch adds a toggle-able setting for the behavior of profile_role on the admin user creation page where checking any of the role checkboxes submits the form, which can be frustrating if you want to assign the user multiple roles without always having to re-type their password, etc.
If you're looking to let the user choose roles on the registration form, then autoassignrole is indeed the way to do (if you need help with this, please start a new support request).
Comment #19
David Stosik commentedHello,
What I'm saying is that even when using this patch, I can't create a new user successfully because every time I check a role, the form gets submitted. Providing a setting to disable this behavior is no fix, it's barely a workaround!
I mean, there are times when clearly auto submitting form on role click is a bad idea, whatever the setting is. What I say is that, for example, user create form should NEVER auto submit form when clicking on a role (or only on specific cases where other useful and depending modules are installed too).
That said, I don't agree with the patch, and I think there is a usability problem there, thus the "needs work" status (because it needs improvement, if not clear enough).
Regards,
David