Skip to content

Commit

Permalink
deprecated :group_by and :group_label options
Browse files Browse the repository at this point in the history
  • Loading branch information
justinfrench committed Feb 25, 2012
1 parent e368596 commit b4a7009
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -4,6 +4,7 @@ HEAD
* 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)
* deprecated :group_by and :group_label (use :collection option with a HTML string generated by Rails' grouped_options_for_select())

2.1.0

Expand Down
7 changes: 0 additions & 7 deletions lib/formtastic/helpers/input_helper.rb
Expand Up @@ -146,22 +146,15 @@ module InputHelper
# @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)
#
# @option options :group_by [Symbol]
# TODO will probably be deprecated
#
# @option options :find_options [Symbol]
# TODO will probably be deprecated
#
# @option options :group_label [Symbol]
# TODO will probably be deprecated
#
# @option options :include_blank [Boolean]
# Specify if a `:select` input should include a blank option or not (defaults to `include_blank_for_select_by_default` configuration)
#
# @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 deprecate & kill `:group_by` & `:group_label`? Should be done with :collection => grouped_options_for_select(...)
# @todo Can we deprecate & kill `:find_options`? Should be done with MyModel.some_scope.where(...).order(...).whatever_scope
# @todo Can we deprecate & kill `:label`, `:hint` & `:prompt`? All strings could be shifted to i18n!
#
Expand Down
2 changes: 2 additions & 0 deletions lib/formtastic/inputs/base.rb
Expand Up @@ -15,6 +15,8 @@ def initialize(builder, template, object, object_name, method, options)
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")
warn_deprecated_option!(:group_by, ":collection option with a HTML string generated by Rails' grouped_options_for_select()")
warn_deprecated_option!(:group_label, ":collection option with a HTML string generated by Rails' grouped_options_for_select()")
end

# Usefull for deprecating options.
Expand Down
3 changes: 0 additions & 3 deletions lib/formtastic/inputs/select_input.rb
Expand Up @@ -132,9 +132,6 @@ module Inputs
# <%= f.input :author, :as => :select, :prompt => "Please select an author" %>
#
#
# @example Group options an `<optgroup>` with the `:group_by` and `:group_label` options (`belongs_to` associations only)
# <%= f.input :author, :as => :select, :group_by => :continent %>
#
# @see Formtastic::Helpers::InputsHelper#input InputsHelper#input for full documentation of all possible options.
# @see Formtastic::Inputs::CheckBoxesInput CheckBoxesInput as an alternative for `has_many` and `has_and_belongs_to_many` associations
# @see Formtastic::Inputs::RadioInput RadioInput as an alternative for `belongs_to` associations
Expand Down
28 changes: 17 additions & 11 deletions spec/inputs/select_input_spec.rb
Expand Up @@ -207,9 +207,11 @@
[@freds_post].each { |post| post.stub!(:to_label).and_return("Post - #{post.id}") }
@fred.should_receive(:posts)

concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:main_post, :as => :select, :group_by => :author ) )
end)
with_deprecation_silenced do
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:main_post, :as => :select, :group_by => :author ) )
end)
end
end
end

Expand Down Expand Up @@ -258,12 +260,14 @@
continent.stub!(:authors).and_return([@authors[i]])
end

concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:author, :as => :select, :group_by => :continent ) )
concat(builder.input(:author, :as => :select, :group_by => :continent, :group_label => :id ) )
concat(builder.input(:author, :as => :select, :group_by => :continent, :member_label => :login ) )
concat(builder.input(:author, :as => :select, :group_by => :continent, :member_label => :login, :group_label => :id ) )
end)
with_deprecation_silenced do
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:author, :as => :select, :group_by => :continent ) )
concat(builder.input(:author, :as => :select, :group_by => :continent, :group_label => :id ) )
concat(builder.input(:author, :as => :select, :group_by => :continent, :member_label => :login ) )
concat(builder.input(:author, :as => :select, :group_by => :continent, :member_label => :login, :group_label => :id ) )
end)
end
end

it_should_have_input_wrapper_with_class("select")
Expand Down Expand Up @@ -303,8 +307,10 @@
it 'should call find with :include for more optimized queries' do
Author.should_receive(:where).with(:include => :continent)

semantic_form_for(@new_post) do |builder|
concat(builder.input(:author, :as => :select, :group_by => :continent ) )
with_deprecation_silenced do
semantic_form_for(@new_post) do |builder|
concat(builder.input(:author, :as => :select, :group_by => :continent ) )
end
end
end
end
Expand Down

0 comments on commit b4a7009

Please sign in to comment.