Permalink
Browse files

deprecated :hint_class and :error_class options (use global configs)

  • Loading branch information...
1 parent ae747d0 commit 274fef1d64a4f7ca93940ccc656a43978668e9da @justinfrench committed Feb 24, 2012
Showing with 17 additions and 25 deletions.
  1. +2 −0 CHANGELOG
  2. +0 −10 README.textile
  3. +0 −7 lib/formtastic/helpers/input_helper.rb
  4. +3 −0 lib/formtastic/inputs/base.rb
  5. +12 −8 spec/helpers/input_helper_spec.rb
View
@@ -2,6 +2,8 @@ HEAD
* removed deprecated buttons DSL, ButtonHelper and commit_button helper
* deprecated the top-level :value option that is only used by HiddenInput
+* deprecated :hint_class option (use global configuration)
+* deprecated :error_class option (use global configuration)
2.1.0
View
@@ -304,16 +304,6 @@ Customize the HTML attributes for the @<li>@ wrapper around every input with the
<% end %>
</pre>
-Customize the default class used for hints on each attribute or globally in the @config/initializers/formtastic.rb@ file. Similarly, you can customize the error classes on an attribute level or globally.
-
-<pre>
- <%= semantic_form_for @post do |f| %>
- <%= f.inputs do %>
- <%= f.input :title, :hint_class => 'custom-html-class', :error_class => 'custom-error-class' %>
- <% end %>
- <% end %>
-</pre>
-
Many inputs provide a collection of options to choose from (like @:select@, @:radio@, @:check_boxes@, @:boolean@). In many cases, Formtastic can find choices through the model associations, but if you want to use your own set of choices, the @:collection@ option is what you want. You can pass in an Array of objects, an array of Strings, a Hash... Throw almost anything at it! Examples:
<pre>
@@ -143,12 +143,6 @@ module InputHelper
# @option options :member_value [Symbol, Proc, Method]
# Override the method called on each object in the `:collection` for use as the `value` attribute in the `<input>` (`:check_boxes` & `:radio` inputs) or `<option>` (`:select` inputs)
#
- # @option options :hint_class [String]
- # Override the `class` attribute applied to the `<p>` tag used when a `:hint` is rendered for an input
- #
- # @option options :error_class [String]
- # Override the `class` attribute applied to the `<p>` or `<ol>` tag used when inline errors are rendered for an input
- #
# @option options :multiple [Boolean]
# Specify if the `:select` input should allow multiple selections or not (defaults to `belongs_to` associations, and `true` for `has_many` and `has_and_belongs_to_many` associations)
#
@@ -167,7 +161,6 @@ module InputHelper
# @option options :prompt [String]
# Specify the text in the first ('blank') `:select` input `<option>` to prompt a user to make a selection (implicitly sets `:include_blank` to `true`)
#
- # @todo Can we kill `:hint_class` & `:error_class`? What's the use case for input-by-input? Shift to config or burn!
# @todo Can we kill `:group_by` & `:group_label`? Should be done with :collection => grouped_options_for_select(...)
# @todo Can we kill `:find_options`? Should be done with MyModel.some_scope.where(...).order(...).whatever_scope
# @todo Can we kill `:label`, `:hint` & `:prompt`? All strings could be shifted to i18n!
@@ -17,6 +17,8 @@ def initialize(builder, template, object, object_name, method, options)
removed_option!(:group_label_method)
warn_deprecated_option!(:value, ":input_html => { :value => '...'}")
+ warn_deprecated_option!(:hint_class, "default_hint_class configuration")
+ warn_deprecated_option!(:error_class, "default_error_class configuration")
end
# Usefull for deprecating options.
@@ -27,6 +29,7 @@ def warn_and_correct_option!(old_option_name, new_option_name)
end
end
+ # Usefull for deprecating options.
def warn_deprecated_option!(old_option_name, instructions)
if options.key?(old_option_name)
::ActiveSupport::Deprecation.warn("The :#{old_option_name} option is deprecated in favour of `#{instructions}` and will be removed in the next version")
@@ -666,11 +666,13 @@ def length_should_be_required(options)
end
it 'should have a custom hint class if I ask for one' do
- hint_text = "this is the title of the post"
- concat(semantic_form_for(@new_post) do |builder|
- concat(builder.input(:title, :hint => hint_text, :hint_class => 'custom-hint-class'))
- end)
- output_buffer.should have_tag("form li p.custom-hint-class", hint_text)
+ with_deprecation_silenced do
+ hint_text = "this is the title of the post"
+ concat(semantic_form_for(@new_post) do |builder|
+ concat(builder.input(:title, :hint => hint_text, :hint_class => 'custom-hint-class'))
+ end)
+ output_buffer.should have_tag("form li p.custom-hint-class", hint_text)
+ end
end
it 'should have a custom hint class defaulted for all forms' do
@@ -728,9 +730,11 @@ def length_should_be_required(options)
}
}
}
- concat(semantic_form_for(@new_post) do |builder|
- concat(builder.input(:title, :hint => true, :hint_class => 'custom-hint-class'))
- end)
+ with_deprecation_silenced do
+ concat(semantic_form_for(@new_post) do |builder|
+ concat(builder.input(:title, :hint => true, :hint_class => 'custom-hint-class'))
+ end)
+ end
output_buffer.should have_tag('form li p.custom-hint-class', @localized_hint_text)
end
end

0 comments on commit 274fef1

Please sign in to comment.