I have a custom Drupal Block with an HTML form in it, can I use the CAPTCHA module to add a CAPTCHA to the bottom of the form within the block?

If so, how?

Thanks,
Jason

Comments

soxofaan’s picture

Status: Active » Closed (won't fix)

If I understand you correctly, that form does not use the Drupal Form API to build/render/process the form?
If so, you're out of luck. CAPTCHA works through the Drupal Form API to alter forms.

(But if that form is managed by the form API, you just have to add the form_id to the list on the CAPTCHA admin page and configure the desired challenge.)

Marko B’s picture

How could i run some custom form trough drupal form api? Like i creat some form in some template file plain form html and then run it somehow trough this api? or is this wrong way and i should do it some other way?

soxofaan’s picture

That's definitely the wrong way. Trying to push a hardcoded html form through the form API is near to impossible or at least horribly awkward.

You should build that form with the form API.
See for example http://api.drupal.org/api/file/developer/topics/forms_api.html/6 for some more info.

Marko B’s picture

thanx. i understand now how its done. But dont know where to put this and how to call it. I put everything from example in template.php and tried calling it with test_page(); or something similar but had no output. how can i call my custom form then in page or node template?

soxofaan’s picture

Well, this is not the right place to discuss this, I don't have the resources to provide this kind of support.
I would recommend to try your luck in the support forums of drupal.

In any case: template.php is not the place to create forms (technically, it's too late in the page life cycle). You should create a drupal module do your magic there (form generation/validation/submission functions, blocks, etc). But as already noted, this is outside the scope of this CAPTCHA issue queue.

good luck

Marko B’s picture

Ok i think i understand, i should build custom module for this to work and only put theme function in template.php. Thanx on pointing me in right direction.

To get back to captcha module then, i guees when i have this form properly run trough D API, i could easily make captcha attached to this with form_id in Captcha admin page?