How to use the htmlfield

4 views
Skip to first unread message

Paul Dorman

unread,
Apr 14, 2011, 2:18:23 AM4/14/11
to Sandbar Library
Hi all,

I'd like to use a ReCaptcha element on my form, which I assumed could
be accomplished using the htmlfield. I have the following in
my :fields declaration:

(forms/htmlfield :be-human (captcha/create-html))

And I get a Ring Stacktrace like this:

core.clj:1245 clojure.core/name
core.clj:106 sandbar.core/property-lookup
forms.clj:81 sandbar.forms/field-label
forms.clj:110 sandbar.forms/htmlfield
RestFn.java:446 clojure.lang.RestFn.invoke
authenticate.clj:73 dev.html.authenticate/eval3213[fn]
MultiFn.java:163 clojure.lang.MultiFn.invoke
authenticate.clj:73 dev.html.authenticate/view-204
authenticate.clj:72 dev.html.authenticate/authenticate-form[fn]
forms.clj:612 sandbar.forms/form-routes[fn]
..
..

I presume this is my mistake :)

Thanks in advance for any help. Also, feel free to tell me if I should
be using something newer than Sandbar 0.3.0.

Regards,
Paul

Brenton

unread,
Apr 14, 2011, 4:41:08 PM4/14/11
to Sandbar Library
It doesn't look like you are doing anything wrong.

I tried to recreate the problem on my end and couldn't.

If you look at the source for htmlfield it should not be calling field-
label in this situation.

https://github.com/brentonashworth/sandbar/blob/0.3.0/src/sandbar/forms.clj#L104

Also, be warned that htmlfield is only for displaying information like
text or images within a form. The text box for entering the captcha
should be another field.

If you can't resolve the problem then open an issue on GitHub and make
sure to include some code that I can use to re-create the problem.

Thanks and good luck,
Brenton

Paul Dorman

unread,
Apr 14, 2011, 8:14:40 PM4/14/11
to sandbar...@googlegroups.com
Thanks Brenton,

yes, having the ReCaptcha present in the form is my first challenge. It did occur to me that I might have to specify a custom field type (though I hope I don't have to), and in the back of my mind I was hoping that you or someone else familiar with Sandbar's internals would fill in the "Show how to create custom form fields" TODO item on the Forms wiki page ;).

The ReCaptcha library creates a JavaScript snippet like:


And this in turn produces a table containing a recaptcha_response_field text field. So presumably I will be able to handle this along with the rest of the form data when submitted.

Cheers,
Paul
Reply all
Reply to author
Forward
0 new messages