put recaptcha in helper method

This commit is contained in:
Mojca Lorber 2016-11-22 17:57:42 +01:00
parent 88890ab65b
commit 48ac289b6e
2 changed files with 18 additions and 6 deletions

View file

@ -0,0 +1,17 @@
module FormTagHelper
def recaptcha_input_tag
if Rails.configuration.x.enable_recaptcha
res = "<div class='form-group "
res << 'has-error' if flash[:recaptcha_error]
res << "'>"
res << recaptcha_tags
if flash[:recaptcha_error]
res << "<span class='help-block'>"
res << flash[:recaptcha_error]
res << '</span>'
end
res << '</div>'
res.html_safe
end
end
end

View file

@ -38,12 +38,7 @@
<span><small><%= t 'users.registrations.new.team_name_help' %></small></span> <span><small><%= t 'users.registrations.new.team_name_help' %></small></span>
</div> </div>
<% if Rails.configuration.x.enable_recaptcha %> <%= recaptcha_input_tag %>
<div class="form-group">
<%= recaptcha_tags %>
<%= flash[:recaptcha_error] %>
</div>
<% end %>
<div class="form-group"> <div class="form-group">
<%= f.submit "Sign up", class: "btn btn-primary" %> <%= f.submit "Sign up", class: "btn btn-primary" %>