Class: SimpleCaptchaInput
- Inherits:
-
Formtastic::Inputs::StringInput
- Object
- Formtastic::Inputs::StringInput
- SimpleCaptchaInput
- Defined in:
- lib/simple_captcha_reloaded/adapters/formtastic.rb
Instance Method Summary collapse
- #captcha_key(captcha) ⇒ Object
- #image_tag(captcha) ⇒ Object
- #refresh_button(captcha) ⇒ Object
- #set_options! ⇒ Object
- #to_html ⇒ Object
Instance Method Details
#captcha_key(captcha) ⇒ Object
29 30 31 |
# File 'lib/simple_captcha_reloaded/adapters/formtastic.rb', line 29 def captcha_key(captcha) builder.hidden_field :captcha_key, value: captcha[:captcha_id] end |
#image_tag(captcha) ⇒ Object
25 26 27 |
# File 'lib/simple_captcha_reloaded/adapters/formtastic.rb', line 25 def image_tag(captcha) template.content_tag(:img, nil, src: captcha[:captcha_url], alt: 'Captcha', class: 'simple-captcha-image') end |
#refresh_button(captcha) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/simple_captcha_reloaded/adapters/formtastic.rb', line 33 def (captcha) template.content_tag :div, class: 'simple-captcha-reload' do template.link_to captcha[:refresh_url], class: [:captcha][:refresh_button_class], data: {remote: true} do I18n.t('simple_captcha_reloaded.refresh_button_html') end end end |
#set_options! ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/simple_captcha_reloaded/adapters/formtastic.rb', line 14 def = { refresh_button: true, id: 'simple_captcha_wrapper' } [:wrapper_html] ||= {} [:captcha] ||= {} [:captcha].reverse_merge!() [:wrapper_html][:id] ||= [:captcha][:id] end |
#to_html ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/simple_captcha_reloaded/adapters/formtastic.rb', line 2 def to_html captcha = SimpleCaptchaReloaded.generate_captcha(id: [:captcha][:id], request: template.request) input_wrapping do label_html << image_tag(captcha) << captcha_key(captcha) << builder.text_field(method, ) << (captcha) end end |