Use Time.now.nsec for text field id

The text field id has to be unique for when you want two different
captchas on the same page.
This commit is contained in:
Guillaume Dott 2015-10-19 10:35:21 +02:00
parent d07827595a
commit 04e016c188
2 changed files with 2 additions and 2 deletions

View File

@ -44,7 +44,7 @@ module ReallySimpleCaptcha::Captcha
content_tag :div, class: 'plain_captcha' do
html = image_tag "data:image/gif;base64,#{image}", alt: "Captcha"
html.concat text_field_tag PlainCaptcha.field_name, nil, required: 'required', autocomplete: 'off'
html.concat text_field_tag PlainCaptcha.field_name, nil, id: "reverse_captcha_#{Time.now.nsec}", required: 'required', autocomplete: 'off'
html
end

View File

@ -11,7 +11,7 @@ module ReallySimpleCaptcha::Captcha
module ViewHelpers
def reverse_captcha_tag
content_tag :div, text_field_tag(ReverseCaptcha.field_name), class: 'reverse_captcha', style: 'display: none'
content_tag :div, text_field_tag(ReverseCaptcha.field_name, nil, id: "reverse_captcha_#{Time.now.nsec}"), class: 'reverse_captcha', style: 'display: none'
end
end