class SimpleForm::Inputs::SimpleCaptchaInput
Public Instance Methods
input(wrapper_options=nil)
click to toggle source
Calls superclass method
# File lib/simple_captcha_reloaded/adapters/simple_form.rb, line 8 def input(wrapper_options=nil) set_options @captcha = SimpleCaptchaReloaded.generate_captcha(id: options[:captcha][:id], request: template.request) if SimpleForm::VERSION[/^3\.0/] input = super() else input = super end refresh = if options[:captcha][:refresh_button] refresh_button(@captcha) else "" end [ image_tag(@captcha), captcha_key(@captcha), input, refresh ].join.html_safe end
Protected Instance Methods
captcha_key(captcha)
click to toggle source
# File lib/simple_captcha_reloaded/adapters/simple_form.rb, line 51 def captcha_key(captcha) @builder.hidden_field :captcha_key, value: captcha[:captcha_id] end
default_options()
click to toggle source
# File lib/simple_captcha_reloaded/adapters/simple_form.rb, line 55 def default_options { refresh_button: true, id: 'simple_captcha_wrapper' } end
image_tag(captcha)
click to toggle source
# File lib/simple_captcha_reloaded/adapters/simple_form.rb, line 47 def image_tag(captcha) template.content_tag(:img, nil, src: captcha[:captcha_url], alt: 'Captcha', class: 'simple-captcha-image') end
set_options()
click to toggle source
# File lib/simple_captcha_reloaded/adapters/simple_form.rb, line 40 def set_options options[:wrapper_html] ||= {} options[:captcha] ||= {} options[:captcha].reverse_merge!(default_options) options[:wrapper_html][:id] ||= options[:captcha][:id] end