Permalink
Browse files

Added form builder support to local variables

  • Loading branch information...
1 parent 76713fd commit 77c0436e28f2955992f420c0750e9d3d52faa707 @stefants committed May 24, 2011
Showing with 4 additions and 8 deletions.
  1. +4 −8 lib/negative_captcha_form_builder.rb
@@ -2,16 +2,14 @@ module ActionView
module Helpers
class FormBuilder
def negative_text_field(captcha, method, options = {})
- obj = @template.instance_variable_get("@#{@object_name}")
html = @template.negative_text_field_tag(captcha, method, options).html_safe
- html = "<div class='fieldWithErrors'>#{html}</div>" if obj.errors.on(method).present?
+ html = "<div class='fieldWithErrors'>#{html}</div>" if @object.errors.on(method).present?
html.html_safe
end
def negative_text_area(captcha, method, options = {})
- obj = @template.instance_variable_get("@#{@object_name}")
html = @template.negative_text_area_tag(captcha, method, options).html_safe
- html = "<div class='fieldWithErrors'>#{html}</div>" if obj.errors.on(method).present?
+ html = "<div class='fieldWithErrors'>#{html}</div>" if @object.errors.on(method).present?
html.html_safe
end
@@ -20,16 +18,14 @@ def negative_hidden_field(captcha, method, options = {})
end
def negative_password_field(captcha, method, options = {})
- obj = @template.instance_variable_get("@#{@object_name}")
html = @template.negative_password_field_tag(captcha, method, options).html_safe
- html = "<div class='fieldWithErrors'>#{html}</div>" if obj.errors.on(method).present?
+ html = "<div class='fieldWithErrors'>#{html}</div>" if @object.errors.on(method).present?
html.html_safe
end
def negative_label(captcha, method, name, options = {})
- obj = @template.instance_variable_get("@#{@object_name}")
html = @template.negative_label_tag(captcha, method, name, options).html_safe
- html = "<div class='fieldWithErrors'>#{html}</div>" if obj.errors.on(method).present?
+ html = "<div class='fieldWithErrors'>#{html}</div>" if @object.errors.on(method).present?
html.html_safe
end
end

0 comments on commit 77c0436

Please sign in to comment.