Closed (duplicate)
Project:
CAPTCHA
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
11 Sep 2007 at 16:04 UTC
Updated:
4 Apr 2009 at 16:55 UTC
Jump to comment: Most recent file
Comments
Comment #1
soxofaan commentedPlease read the documentation (at ?q=admin/user/captcha):
* Check the box "Add captcha adminstration links to forms"
* go to a forward form
* click on the link "Place a captcha challenge here for untrusted users."
* set the captcha type and save the settings.
* done
The only problem I see is that the captcha isn't placed above the "send message" button.
A quick fix for this is changing line 372 of forward.module from
$form['message']['submit'] = array(to
$form['submit'] = array(Comment #2
soxofaan commentedthis issue can probably be closed now
Comment #3
seanrI just found this issue and am working on fixing Forward, but have run into a problem. When you set Forward to appear in a form below the node instead of as a link, it gets wrapped in a collapsible fieldset. For obvious reasons, I want the submit button to be inside that fieldset. Is there some way I can define in my module where the CAPTCHA element should go if the user enables it?
Comment #4
soxofaan commentedNo, the CAPTCHA module adds the CAPTCHA form elements at the toplevel of the form and tries to place it just above the submit/save button if it can find one (also at toplevel)
Do you have something in mind on how to hint CAPTCHA module where to place the CAPTCHA elements?
CAPTCHA adding happens in captcha_hook_alter, so only the form array is available there.
Maybe a toplevel $from['#captcha_placement_hint'] property to point to the place and weight to use or something?
Comment #5
seanrSomething like that would be extremely helpful. Maybe like this:
$form['#captcha_placement'] = 'message/submit';
Not sure how best to describe the path through the array structure, though.
In this case, even just having it look a level deeper if it doesn't find one on the top level would be helpful. I can't imagine a situation where the submit button would be nested more than one level deep, so maybe CAPTCHA would check the top level first, then look inside the last child of the top level (most likely place the submit would be if not in the top level).
Comment #6
soxofaan commentedFor the moment I don't have time to work on this
and there are things in the tracker that are more urgent.
So let's say for the time being that patches are welcome ;)
Comment #7
Vorus commentedI ran into a similar issue where I needed the captcha to appear within a fieldset. I modified the captcha module so that the captcha is placed on the same level as the first submit button found on the form.
Comment #8
soxofaan commentedpatch from #7 gives 4 failed hunks out of 12 for 5.x-3.x-dev
I also think that $place is not a good name for a form element
About the function _captcha_find: the name is not very descriptive, there are some indentation issues and it can return an array or a boolean, which is a bit dangerous and at least requires proper documentation
Comment #9
Vorus commentedAlright. I'll go through and make those changes and modify it against 5.x.3.x-dev and get it up tonight.
Comment #10
Vorus commentedI went through the code and cleaned it up, commented and put it in line with the code standards.
The captcha should now be placed above the first submit button found on the form. It is not very specific or picky but it was written as a quick hack. I have some ideas for adding a $form['#captcha-hint'] implementation and I will look into implementing them if there is still a need.
Note: I did my best with the diff program and I think I got it right this time with the patch but I'm not certain. Feedback is appreciated.
Comment #11
syngi commentedThanks Vorus,
I applied the patch (patch < captcha-174756-10.patch) and got:
Hunk #3 FAILED at 543.
Hunk #4 succeeded at 552 (offset -1 lines).
Hunk #5 succeeded at 583 with fuzz 2 (offset -8 lines).
Hunk #6 succeeded at 677 with fuzz 2 (offset -12 lines).
Hunk #7 succeeded at 697 (offset -12 lines).
1 out of 7 hunks FAILED -- saving rejects to file captcha.module.rej
but the capcha shows up in the form now. So no idea what went wrong.
Perhaps version mismatch? I have "// $Id: captcha.module,v 1.42.2.40 2007/12/03 01:16:42 robloach Exp $" in the head of my captcha.module file.
Comment #12
PeterZ commentedThe solution in #1 worked for me in Drupal 6.10 and Forward 6.x 1.2. (To get the Captcha appearing above the send message submit button on the forward page.)
Comment #13
soxofaan commentedFYI: #423736: Big update of 6.x-2.x branch (keyword: hook_elements)
The patch in that thread provides a more powerful automatic placement of the CAPTCHA widget
The "forward" form is now handled correctly for example.
The work planned in #423736: Big update of 6.x-2.x branch (keyword: hook_elements) also intends to provide means for hinting the CAPTCHA placement
(setting this one as a duplicate)