I would like for the Mollom block to have the most weight on the user registration page all pages in which it appears, especially the user registration page. (Core is 6.x).
Currently the order is (on the reg page):
- Account Info
- Mollom
- Custom profile_ fields
- Upload user pic (Reg with Pic module)
How would I change the weight of the Mollom captcha portion from 2 to 4?
Thanks in advance...
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 477580-d5-captcha_weight.13.patch | 1.73 KB | jeffschuler |
| #12 | mollom-DRUPAL-5.captcha-weight.12.patch | 1.11 KB | sun |
| #9 | 477580-d5-captcha_weight.patch | 1.27 KB | jeffschuler |
Comments
Comment #1
xtex404 commentedIt's a known bug, but it doesn't look like a new release has been made since it was fixed. Check out http://drupal.org/node/368795 ... I just applied that patch to the module and it moved the Captcha down to the bottom of the form.
To quickly patch it, just change into the mollom/ directory where mollom.module lives and run:
# curl http://drupal.org/files/issues/mollom_weight.patch | patch -p0
Comment #2
jerdiggity commentedWorked like a charm. Much appreciated. :)
Comment #3
jerdiggity commentedComment #5
venusrising commentedWill this patch ever be applied to a version?
Comment #6
jerdiggity commentedPlease upgrade to version 6.x-1.9. Issue appears to have been addressed & committed to HEAD (probably by Dries) -- see line 388 of mollom.module.
Comment #8
jeffschulerMollom 5.x positions the CAPTCHA before user profile fields on the registration form.
Does the
#pre_renderhack that the D5 version uses prevent us from inserting the CAPTCHA at the bottom of the form?Comment #9
jeffschulerIn 5.x-1.8, Mollom's CAPTCHA's weight on a form is set using the minimum of the Submit and Preview elements:
'#weight' => min($form['submit']['#weight'], $form['preview']['#weight']) + 1,On forms without a preview button, (like user registration,) this effectively sets the CAPTCHA's #weight to 1.
The attached patch (for 5.x-1.8) adds a little logic for this situation, positioning Mollom's CAPTCHA at the bottom of the user registration form.
Comment #10
dries commented- I haven't tested this patch yet but it has some minor coding style issues. We write "} else {" over two lines.
- Looking at the code, I'd think it makes some unfair assumptions. For example, I think it breaks when you have a form with both a Preview and a Submit button.
Comment #11
dries commentedComment #12
sunI think that this should do the trick, as I think that the cause of the issue is that you can configure individual weights for the profile fields.
Overall, however, I'd hesitate to commit this patch, as it can be considered as a very late API change. It's probably better to go with a stop-gap fix, just for the user registration form, and only if Profile module is enabled (not sure if we can check whether it actually added fields to the form, but of course, that would be even better).
Comment #13
jeffschulerThanks for your reviews!
The underlying issue here is that the existing code breaks when there is no Preview button: when
$form['preview']['#weight']is undefinedmin(...), returns0, regardless of the value of$form['submit']['#weight'].I've fixed logic and style errors in the first patch. I mis-typed
min()asmax()in my original patch. I'm not trying to change any logic; just account for edge conditions. This patch goes one step further to explicitly cover all cases. (If neither$form['preview']['#weight']nor$form['submit']['#weight']are set,$form['captcha-solution']['#weight']defaults to 1, (which is the outcome in the existing code, too.))@sun, I'm not sure how this amounts to an API change -- I'll certainly defer to you there -- but maintaining the
min(...)function as such seems pointless when one of its parameters being undefined, (a common scenario,) spoils the logic...Comment #14
dries commentedJeff, could you test sun's patch in #12? Does that work for you?
The patch in #13 seems to make sense too, although we tend to use isset() instead of is_int().
If #12 works, I'd prefer to commit #12 so let's test #12 first. Thanks!
Comment #15
jeffschulerYes, sun's patch in #12 works for the user registration form in question.
Comment #16
dries commentedIn that case, I'm inclined to go with #12, unless there are other unexpected regressions.
Comment #17
sunThanks for testing, jeffschuler! We may go with my #12 then. I'm merely thinking of other modules and custom, site-specific code that may expect certain form element weights on forms.
All forms enabled to be protected by Mollom currently get a preview/submit weight of (+)2 while Mollom ends up on (+)1. With this patch, form element weights are "suddenly" changing from those values to (+)100 and (+)101. Existing code (rather thinking of custom code) may rely on those weights, squeezing further elements in between by using decimal weights, i.e., 0.8 or 1.5, or trying to append things to the end of the form. In the end, I'm just trying to say that this weight change can break certain designs. But it also may not.
But then again, usage statistics for D5 only mention a small amount of installations (next to Drupal 5 overall being unsupported with the release of D7 anyway), so I'm not sure whether it's worth to think this perfect.
Comment #18
dries commentedCommitted #12 to DRUPAL-5. Let's see what happens ... would love to get some more test feedback.