No more :options.

This commit is contained in:
José Valim 2009-12-11 00:34:20 -02:00
parent 725ca0f4a1
commit ce29c4c1d5
3 changed files with 13 additions and 12 deletions

View File

@ -56,14 +56,14 @@ module SimpleForm
collection = (options[:collection] || self.class.boolean_collection).to_a
detect_collection_methods(collection, options)
options[:options][:include_blank] = true unless options[:options].key?(:include_blank)
options[:include_blank] = true unless options.key?(:include_blank)
args.push(collection, options[:value_method], options[:label_method])
end
# Apply default behavior for inputs that need extra options, such as date
# and time selects.
def apply_options_behavior(args)
args << options[:options]
args << options
end
# Adds default html options to the input based on db column information.

View File

@ -17,7 +17,8 @@ module SimpleForm
# f.input :name, :hint => 'My hint'
# end
#
# This is the output html (only the input portion, not the form):
# This is the output html (only the input portion, not the form):
#
# <label class="string required" for="user_name">
# <abbr title="required">*</abbr> Super User Name!
# </label>
@ -48,9 +49,9 @@ module SimpleForm
# == Options
#
# Some inputs, as datetime, time and select allow you to give extra options, like
# prompt and/or include blank. Such options are given in the :options key.
# prompt and/or include blank. Such options are given in plainly:
#
# f.input :created_at, :options => { :include_blank => true }
# f.input :created_at, :include_blank => true
#
# == Collection
#

View File

@ -86,9 +86,9 @@ class InputTest < ActionView::TestCase
end
test 'input should be able to pass options to datetime select' do
with_input_for @user, :created_at, :datetime, :options => {
with_input_for @user, :created_at, :datetime,
:disabled => true, :prompt => { :year => 'ano', :month => 'mês', :day => 'dia' }
}
assert_select 'select.datetime[disabled=disabled]'
assert_select 'select.datetime option', 'ano'
assert_select 'select.datetime option', 'mês'
@ -104,9 +104,9 @@ class InputTest < ActionView::TestCase
end
test 'input should be able to pass options to date select' do
with_input_for @user, :born_at, :date, :options => {
with_input_for @user, :born_at, :date, :as => :date,
:disabled => true, :prompt => { :year => 'ano', :month => 'mês', :day => 'dia' }
}
assert_select 'select.date[disabled=disabled]'
assert_select 'select.date option', 'ano'
assert_select 'select.date option', 'mês'
@ -123,9 +123,9 @@ class InputTest < ActionView::TestCase
end
test 'input should be able to pass options to time select' do
with_input_for @user, :delivery_time, :time, :options => {
with_input_for @user, :delivery_time, :time, :required => true,
:disabled => true, :prompt => { :hour => 'hora', :minute => 'minuto' }
}
assert_select 'select.time[disabled=disabled]'
assert_select 'select.time option', 'hora'
assert_select 'select.time option', 'minuto'
@ -191,7 +191,7 @@ class InputTest < ActionView::TestCase
end
test 'input should not set include blank if otherwise is told' do
with_input_for @user, :age, :select, :collection => 18..30, :options => { :include_blank => false }
with_input_for @user, :age, :select, :collection => 18..30, :include_blank => false
assert_no_select 'select option[value=]', ""
end