Module: ActsAsTextcaptcha::TextcaptchaHelper

Defined in:
lib/acts_as_textcaptcha/textcaptcha_helper.rb

Instance Method Summary collapse

Instance Method Details

#textcaptcha_fields(f, &block) ⇒ Object

builds html form fields for the textcaptcha



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/acts_as_textcaptcha/textcaptcha_helper.rb', line 5

def textcaptcha_fields(f, &block)
  model        = f.object
  captcha_html = ''
  if model.perform_textcaptcha?
    if model.textcaptcha_key
      captcha_html += f.hidden_field(:textcaptcha_key)
      if model.textcaptcha_question
        captcha_html += capture(&block)
      elsif model.textcaptcha_answer
        captcha_html += f.hidden_field(:textcaptcha_answer)
      end
    end
  end

  captcha_html.html_safe
end