Sha256: d2336631929ccb1672d3a45669763f93da40150e0c9b84f1b8ba2c86bb6a2655
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
# Override the form_tag helper to add zero captcha spam protection to forms. module ActionView module Helpers module FormTagHelper def form_tag_html_with_zero_captcha(options) zero_captcha = options.delete(:zero_captcha) || options.delete('zero_captcha') html = form_tag_html_without_zero_captcha(options) if zero_captcha captcha = "".respond_to?(:html_safe) ? zero_captcha_html.html_safe : zero_captcha if block_given? html.insert(html.index('</form>'), captcha) else html += captcha end end html end alias_method :form_tag_html_without_zero_captcha, :form_tag_html alias_method :form_tag_html, :form_tag_html_with_zero_captcha private def zero_captcha_html zero_captcha_fields.collect do |name, value| content_tag :div do hidden_field_tag(name, 'verify') + javascript_tag do "jQuery('input[name=#{name}]').val('#{value}')".html_safe end end end.join end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
zero-captcha-0.0.5 | lib/zero-captcha/form_tag_helper.rb |
zero-captcha-0.0.4 | lib/zero-captcha/form_tag_helper.rb |