Skip to content

Commit

Permalink
deprecated errors_on/inline_errors_for helper
Browse files Browse the repository at this point in the history
  • Loading branch information
justinfrench committed May 11, 2011
1 parent 30e7b49 commit 17e3d2c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
5 changes: 4 additions & 1 deletion lib/formtastic/helpers/inputs_helper.rb
Expand Up @@ -322,7 +322,10 @@ def inputs(*args, &block)
# <%= f.errors_on(:body) %>
# </li>
# <% end %>
def inline_errors_for(method, options = {}) #:nodoc:
#
# @deprecated See the README for the currently supported approach to custom inputs.
def inline_errors_for(method, options = {})
ActiveSupport::Deprecation.warn('inline_errors_for and errors_on are deprecated and will be removed on or after version 2.1', caller)
if render_inline_errors?
errors = error_keys(method, options).map{|x| @object.errors[x] }.flatten.compact.uniq
send(:"error_#{inline_errors}", [*errors], options) if errors.any?
Expand Down
20 changes: 12 additions & 8 deletions spec/errors_spec.rb
Expand Up @@ -116,10 +116,12 @@
end

it 'should return nil when inline_errors config is :sentence, :list or :none' do
[:sentence, :list, :none].each do |config|
with_config :inline_errors, config do
semantic_form_for(@new_post) do |builder|
builder.errors_on(:title).should be_nil
with_deprecation_silenced do
[:sentence, :list, :none].each do |config|
with_config :inline_errors, config do
semantic_form_for(@new_post) do |builder|
builder.errors_on(:title).should be_nil
end
end
end
end
Expand All @@ -132,10 +134,12 @@
end

it 'should return nil when inline_errors config is :sentence, :list or :none' do
[:sentence, :list, :none].each do |config|
Formtastic::FormBuilder.inline_errors = config
semantic_form_for(@new_post) do |builder|
builder.errors_on(:title).should be_nil
with_deprecation_silenced do
[:sentence, :list, :none].each do |config|
Formtastic::FormBuilder.inline_errors = config
semantic_form_for(@new_post) do |builder|
builder.errors_on(:title).should be_nil
end
end
end
end
Expand Down

0 comments on commit 17e3d2c

Please sign in to comment.