2008/8/26 Michele Beltrame <[EMAIL PROTECTED]>: > Hi Carl! > >> That should work - but formfu won't be aware it's a form field - so it >> would be a bit of a hack. >> You could also use a Src element, if you don't want the DIV around the >> reCAPTCHA markup. > > I managed to make this work but, as you said, it turned out to be a real > dirty hack as the reCAPTCHA code creates two fields of which HTML::FormFu > can't be aware. > >> If you've got the time/inclination - I would suggest asking the author >> of Captcha::reCAPTCHA if he'd accept a patch to expose the >> functionality, without having to use the html output. >> If you were to patch Captcha::reCAPTCHA to do that - I'd be happy to >> code up a formfu element that to interface with it. > > I guess this could be cone. However, checking at the Captcha::reCAPTCHA > code, is seems quite short and simple - and the most part of it is > devoted to creating the HTML, which we would need to rewrite anyway. So > I wonder if it wouldn't be easier to just implement a reCAPTCHA FormFu > element from scratch.
I've added a reCAPTCHA element to trunk. In the end, I decided it would be best to use Captcha::reCAPTCHA's get_html() method, so the formfu form doesn't get messed up with unnecessary params. There's a reCAPTCHA constraint that uses Captcha::reCAPTCHA's check_answer() method. But don't add the constraint yourself - the element automatically does it for you. Basically, you just need to add the element, like so: elements: - type: reCAPTCHA name: recaptcha public_key: xxx private_key: yyy The name() is required - you probably won't need to use it anywhere, but it's needed for the constraint to work - just make sure you set it to a name that's not used in the current form. If the user responds correctly, submitted_and_valid() and has_errors() will pass OK, and you won't see anything recaptcha-related in your params() If the user responds incorrectly - the constraint will just cause submitted_and_valid() and has_errors() to fail. There's also a recaptcha_options() method which takes a hashref of options to pass to the reCAPTCHA JS object - e.g. { lang: 'de' } I've tested it, and it works fine both with JS on and off. It doesn't support the ajax version, though. And the test I've created doesn't really test anything properly - just the expected html. let me know how it works for you. Carl _______________________________________________ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu