Sha256: e97d5f452b97e16fb2e5b25f0b6464d0f439034de6cf2bf18bca50ec0a3dc95e

Contents?: true

Size: 621 Bytes

Versions: 4

Compression:

Stored size: 621 Bytes

Contents

# frozen_string_literal: true

module ActsAsTextcaptcha
  module TextcaptchaHelper
    def textcaptcha_fields(form, &block)
      build_textcaptcha_form_elements(form, &block) if form.object.perform_textcaptcha? && form.object.textcaptcha_key
    end

    private

    def build_textcaptcha_form_elements(form, &block)
      captcha_html = form.hidden_field(:textcaptcha_key)
      if form.object.textcaptcha_question
        captcha_html += capture(&block)
      elsif form.object.textcaptcha_answer
        captcha_html += form.hidden_field(:textcaptcha_answer)
      end
      captcha_html.html_safe
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
acts_as_textcaptcha-4.7.1 lib/acts_as_textcaptcha/textcaptcha_helper.rb
acts_as_textcaptcha-4.7.0 lib/acts_as_textcaptcha/textcaptcha_helper.rb
acts_as_textcaptcha-4.6.0 lib/acts_as_textcaptcha/textcaptcha_helper.rb
acts_as_textcaptcha-4.5.2 lib/acts_as_textcaptcha/textcaptcha_helper.rb