1

我不确定如何使用自定义主题 Recaptcha 小部件设置样式

http://github.com/ambethia/recaptcha

我想调整小部件的大小以适应侧边栏中的表单。

如果我做

<%= recaptcha_tags :display => {:theme => 'custom', :custom_theme_widget => 'recaptcha_widget'} %>

并添加

<div id="recaptcha_widget">
    <div id="recaptcha_image"></div>
    <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" />
</div>

按照

Recaptcha - 表单定制

我只得到响应输入字段,以及 img 标签的源属性中的错误消息

src="http://optim.coral.cs.cmu.edu/error/TypeError_Result_of_expression_____recaptcha_response_field_____null__is_not_an_object_"

有没有人找到使用 Ambethia gem 自定义主题 Recaptcha 小部件的好方法?

4

2 回答 2

0

我有同样的问题。但是如果你放置recaptcha_widget之前的html代码recaptcha_tags,一切都OK。

于 2010-07-13T07:00:50.917 回答
0

我在没有助手的情况下这样做了。如果我在脚本标签中传递了公钥,但在 environment.rb 中没有:

    #recaptcha_container
      %label{ :for => "recaptcha_response_field" }
        Enter the two words below:
      %input#recaptcha_response_field.text{ :name => "recaptcha_response_field", :type => "text" }
      #recaptcha_image
      %p
        Choose captcha format:
        %a{ :href => "javascript:Recaptcha.switch_type('image');" }
          Image
        or
        %a{ :href => "javascript:Recaptcha.switch_type('audio');" }
          Audio
      %input#recaptcha_reload_btn{ :type => "button", :value => "Get new words", :onclick => "Recaptcha.reload();" }
    %script{ :src => "http://api.recaptcha.net/challenge?k=INSERT_KEY_HERE", :type => "text/javascript" }
    %noscript
      %iframe{ :src => "http://api.recaptcha.net/noscript?k=INSERT_KEY_HERE" }
        height="300" width="500" frameborder="0">
      %textarea{ :name => "recaptcha_challenge_field", :rows => "3", :cols => "40" }
于 2010-06-29T22:14:59.763 回答