I would appreciate some example code of how to include a image captcha withing a form using the forms API. I'm developing my own module and would like to employ captchas in certain circumstances. If there is an example out there that I have missed I apologize.
Comments
Comment #1
soxofaan commentedYou don't need any programming to add a CAPTCHA to a form. You can add CAPTCHA's to almost every drupal generated form. Just use the "Add CAPTCHA adminstration links to forms" option in the CAPTCHA settings.
Comment #2
igable commentedWow! Very impressive. That's a very large misunderstanding on my part. I was reading to code trying to figure what function to call.
As a follow up, is there a way for me to force the use of a captcha on a particular form when someone installs my module. The method will certainly do for me for now.
Thanks for the super quick response.
Comment #3
soxofaan commentedIt's not impossible, but I would not recommend to do this.
Why would you want to do this? If someone installs your module on his site it's up to him if he want CAPTCHA protection, no? Maybe he doesn't want CAPTCHA but another spam fighting system.
It doesn't seem a good idea to create a dependency when it's not really needed.
Comment #4
igable commentedVery good point. Enforcing it would be counter the whole idea of modularity. There is few odd cases where you might want to force the use of a captcha system of some kind. For example in the case of a form that send email to arbitrary addresses. Forward a story to a friend feature for example.
Comment #5
soxofaan commentedI wouldn't force the user, I would just suggest/recommend something. It's up to him to decide if he needs CAPTCHA, another spam filter, or maybe nothing (if he can trust all his users for example).
It's indeed all about modularity, which makes Drupal rock.
Comment #6
igable commentedOk I'm happy. Thanks very much.
Comment #7
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #8
baloneysammitch commentedI have the exact same need, but for different reasons, so I'm re-opening this issue. My problem is that I've themed my form using a tpl page (http://drupal.org/node/98253) and I've made it so the captcha does not render. However, the site still recognizes that the captcha is active and requires an answer before the form is submitted. I need the code that renders the captcha into the form. Is there such a "form API" for captcha? Also, is there any work on the subject of integrating captcha into the CCK? It would make rendering it on specific custom forms much easier.
Comment #9
soxofaan commentedCAPTCHA uses the standard form API, there is no custom form rendering involved, you can render the CAPTCHA just like you render other form elements.
That doesn't make a lot of sense to me: CCK is for defining content bricks, while CAPTCHA is a sort of authentication thing. I don't see how you can combine these concepts.
Comment #10
baloneysammitch commentedThank you for your reply. I got around the captcha rendering issue by using a page-my_form-tpl.php modification.
CCK integration makes sense to me for a few reasons:
1. A Captcha is just another input field. If you are building a custom form through the CCK, the only way to get the Captcha to display on it is to use the admin checkbox, go to your form, find the new captcha fieldset at the bottom and enable it. This seems a little counterintuitive.
2. CCK has all sorts of fields that go through validation, such as e-mail fields, social security numbers, phone numbers, and so on. Captchas are just that-- validation.
3. You would have more control over the order in which the Captcha appears on the form. As it is now, you must put it at the bottom. (Though I don't know why you would want it anywhere else... I'm just exploring a few of the added benefits that would come from using CCK :D )
Just something to think about.
Comment #11
soxofaan commentedI'm still not convinced. But the usability issues you mention make sense.
This clearly needs some more discussion and thought.
If we would implement this, I think we should start with the Drupal 6 version.
Comment #12
soxofaan commentedWith the usage of hook_elements now (#423736: Big update of 6.x-2.x branch (keyword: hook_elements)), it should be fairly easy to provide a CCK CAPTCHA widget.
However, I'm planning to do this after the release of a stable 6.x-2.0 version, for example in a 6.x-2.1.
Comment #13
bobby endarr ramdin commentedwebform?
Comment #14
summit commentedSubscribing, CCK widget would be great!
Greetings,
Martijn
Comment #15
wundo commented