Skip to content

Commit

Permalink
Temporarily override the template's field_error_proc. Fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
stouset committed Oct 4, 2011
1 parent 5483707 commit f975f61
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/twitter_bootstrap_form_for/form_builder.rb
Expand Up @@ -27,12 +27,18 @@ class TwitterBootstrapFormFor::FormBuilder < ActionView::Helpers::FormBuilder
# +legend+ text.
#
def inputs(legend = nil, &block)
# TODO: don't wrap error fields in field_with_error divs
# ActionView::Base.field_error_proc = ->(html_tag, instance) { html_tag }
# stash the old field_error_proc, then override it temporarily
original_field_error_proc = template.field_error_proc
template.field_error_proc = ->(html_tag, instance) { html_tag }

# TODO: fix field with errors for good
template.field_error_proc = ->(html_tag, instance) { html_tag }
template.content_tag(:fieldset) do
template.concat template.content_tag(:legend, legend) unless legend.nil?
block.call
end
ensure
template.field_error_proc = original_field_error_proc
end

#
Expand Down

0 comments on commit f975f61

Please sign in to comment.