Hi
I have Botcha on form that is located on block that is loaded via AjaxBlocks drupal.org/project/ajaxblocks
The thing is that it's not being hidden, because page isn't reloaded.
Can You do something with that or advice me something??

Comments

iva2k’s picture

Version: 6.x-1.6 » 6.x-1.x-dev
Category: bug » feature

I am pretty sure Botcha won't work for any form served via AJAX, as it requires running custom javascript generated for each form. AJAX forms don't run javascript or load additional CSS.

I'm moving this to a feature request. I know how to make it work (with prepared page-wide recipes on the page for all AJAX forms and detecting use of AJAX), but it will take time which I currently don't have.

barteque’s picture

I made a little modification to the botha module [my local copy]

a put some inline javascript which is hiding the "field that should be hidden"

but that way the field is not being properly filled in... :/

iva2k’s picture

Title: Botcha on block loaded via Ajaxblocks » Make BOTCHA work with AJAX
hles’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
ryoken’s picture

Thanks for this great module!

Using BOTCHA with Webforms module works fine, except when you have a file attachment/upload widget - this appears to be AJAX-based. It would be nice if I could get file upload fields working with BOTCHA.

PatchRanger’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev

Version 7.x-2.x now has "AJAX friendly" recipe book, which consists of only non-JS recipes. It makes it playing nice with AJAX and so on.
#1832232: Make the BOTCHA module to work with AJAX comment module closed as a duplicate of this thread.

PatchRanger’s picture

The great leap to this functionality is here: #1849182: [META] Add Selenium tests for JavaScript recipes full test coverage. When it gets closed, we'll have a plan (I hope) how to achieve this.

Aurochs’s picture

Unfo Botcha breaks my javascript. Unfo i understood that too late and spent 2 days giguring out the problem!
So i will turn back to the module which is meant for merging - uncaptuolous + spamicide+honeypot.
That three in combination dont give me troubles neither with spam nor with js.
will be looking forward to botcha working with js.

PatchRanger’s picture

@Aurochs First of all thanks a lot for reporting the problem - it helps to make the module even better.

Unfo Botcha breaks my javascript. Unfo i understood that too late and spent 2 days giguring out the problem!

That's really unfo. Right now I am working on #1849182: [META] Add Selenium tests for JavaScript recipes full test coverage, which will let to fix the root of such kind of problems. The plan is as follows:

PatchRanger’s picture

PatchRanger’s picture

Closed #1880198: Botcha breaks file uploads as a duplicate of this one.

sororitypin’s picture

Version: 7.x-2.x-dev » 7.x-3.1

Anyone working on this?

iva2k’s picture

Version: 7.x-3.1 » 7.x-3.x-dev

Not that I know of. I will give priority to reviewing submitted patches.

tomogden’s picture

I'm not sure I follow where this issue has gone.

Let me describe my own use case to make this issue a little more searchable and attract some helpful attention:

  1. Given a public Comments form with a location field drop down for selecting the province of a country.
  2. BOTCHA sets the $form_state['no_cache'] = TRUE so that is cannot be cached.
  3. User selects country, prompting AJAX to populate the provinces.
  4. AJAX executes but automatically rejects the form as illegitimate because it is not found in the cache.
  5. AJAX returns warning "Invalid form POST data." in the logs via watchdog.
  6. The provinces drop down remains empty.

As to a solution, I don't know what has been considered, but the simple method would be to add a checkbox in the configuration page that says something like, "Allow AJAX in BOTCHA forms." This checkbox in turn would deactivate the 'no_cache' flag. Since forms caching is considered a security measure, I don't quite understand why it's used at all in BOTCHA.

Any feedback?

tomogden’s picture

Status: Active » Fixed

It appears to be work in 7.x-3.x-dev.

tomogden’s picture

Status: Fixed » Active

My mistake. The only way 7.x-3.x-dev will all for AJAX is if the given form is disabled, which is no help at all.

The new 3.x organizes tests into recipes within recipe books, including a recipe book that is called "AJAX friendly". Unfortunately, the 'no_cache' call is in the apply() function that handles all BOTCHA-enabled forms, regardless of recipe, and even if the recipe book selection is "none".

The 'no_cache' setting was introduced in #1510082-1: BOTCHA D7: form rebuild is not happening properly on invalid submission.

As @iva2k put it,

It cannot be used in BOTCHA as we need to rebuild more than one element and add JS and CSS.
jun’s picture

Category: feature » bug

I'm afraid I've found an AJAX form use that doesn't play well with BOTCHA. Using Inline Entity Forms widgets in their Multiple Values mode breaks. The way it breaks is that clicking on the Add Existing Node or Add New Node buttons simply doesn't do anything.

My setup uses the Inline Entity Form as a Profile2 field displayed in the user_registration_form. It works fine without Botcha enabled.

Enabling the Botcha module breaks the form right away. Configuring the form for Ajax Friend recipes doesn't fix it, and neither does choosing "None" as a Recipe.

iva2k’s picture

Category: bug » feature

After reading it carefully, #17 seems like a different issue. Please open a separate issue for the very special case, otherwise you may wait a much longer time to get it fixed.

burningdog’s picture

I have the same issue with hierarchical_select - drupal tries to look up the form id in the cache_form by calling ajax_get_form() - which loads up the cached form through the following line in form_get_cache():

<?php
cache_get('form_' . $form_build_id, 'cache_form')
?>

My value of form_build_id is form-LZmfUB5y3Y9rM21HepB9_f13xlST99Xj6SwAGP4jlLw but in the cache_form table it's prefixed with "botcha", so that it is botcha_form-LZmfUB5y3Y9rM21HepB9_f13xlST99Xj6SwAGP4jlLw.

So how we fix this - I have no idea. 2 years ago iva2k had an idea at #1.

ARUN AK’s picture

Hi,

I am using Asaf (ajax submit for any form) module for ajax form submission and I have enabled ajax submission for comment form.

But if enable the botcha for a ajax enabled form then ajax submission will not working. I tried to change recipe in to AJAX friendly, but still it is not working. Please help me.

Thanks and Regards
ARUN AK

jcmartinez’s picture

It would be great if someone (...or iva2k) could explain a bit more the idea at #1. I'd be happy to put some effort into a fix and a patch but at this point and with so limited information it is not clear to me how to fix it.

BTW - As suggested on https://drupal.org/node/1561468, I tried adding this...

if (module_exists('botcha')) {
        $form_state['no_cache'] = FALSE; // When using with BOTCHA.
      }

...to my hook_form_alter() but it did not help.

iva2k’s picture

The idea I mentioned in #1 is a multi-step development.

1. Change the mechanism Botcha uses to modify forms - move the logic from form_alter to one (or few) of hooks that are called later in the process. Code in Mollom captcha can be used as a template. (Background info: Botcha used code found in contrib Captcha module. Mollom came later with a different and better technique as it is done by Dries).

2. Once item 1 is done, AJAX handling hooks have to be added to Botcha. Details for this I don't remember as I looked at it long time ago. Basically we need to transport new AJAX and CSS code to the form via all AJAX updates. Mollom code may give some ideas.

3. Create/modify recipes to work with AJAX hooks.