From fb1f52dbc5855e3e33bc441ec89c9bd519d416cb Mon Sep 17 00:00:00 2001 From: Volmer Soares Date: Wed, 13 Nov 2013 14:44:42 -0200 Subject: [PATCH 1/8] Support to date, datetime and time inputs. I changed `DateTimeInput` to support the new HTML5 form helpers that comes with Rails 4 (`date_input`, `datetime_input` and `time_input`) instead of rendering datetime selects: For example, this input: ```erb <%= f.input :born_on, as: :date %> ``` Will render: ```html ``` Datetime selects are still present, but only when HTML5 compatibility is disabled. It's also possible to render selects even with HTML5 on, by setting the `html5` option to false. If we wanted to use an old date select on the example above, we should do: ```erb <%= f.input :born_on, as: :date, html5: false %> ``` Closes #844. --- lib/simple_form/inputs/date_time_input.rb | 16 ++- test/inputs/datetime_input_test.rb | 137 +++++++++++++++++----- 2 files changed, 124 insertions(+), 29 deletions(-) diff --git a/lib/simple_form/inputs/date_time_input.rb b/lib/simple_form/inputs/date_time_input.rb index 64fd326f..ca40b383 100644 --- a/lib/simple_form/inputs/date_time_input.rb +++ b/lib/simple_form/inputs/date_time_input.rb @@ -1,8 +1,14 @@ module SimpleForm module Inputs class DateTimeInput < Base + enable :html5 + def input - @builder.send(:"#{input_type}_select", attribute_name, input_options, input_html_options) + if use_html5_inputs? + @builder.send(:"#{input_type}_field", attribute_name, input_html_options) + else + @builder.send(:"#{input_type}_select", attribute_name, input_options, input_html_options) + end end private @@ -19,6 +25,14 @@ module SimpleForm position = ActionView::Helpers::DateTimeSelector::POSITION[position] "#{attribute_name}_#{position}i" end + + def use_html5_inputs? + if input_options.key?(:html5) + input_options[:html5] + else + html5? + end + end end end end diff --git a/test/inputs/datetime_input_test.rb b/test/inputs/datetime_input_test.rb index b1a77354..6c388764 100644 --- a/test/inputs/datetime_input_test.rb +++ b/test/inputs/datetime_input_test.rb @@ -1,18 +1,69 @@ # encoding: UTF-8 require 'test_helper' -# Tests for all different kinds of inputs. -class DateTimeInputTest < ActionView::TestCase - # DateTime input - test 'input should generate a datetime select by default for datetime attributes' do +# Tests for datetime, date and time inputs when HTML5 compatibility is enabled in the wrapper. +class DateTimeInputWithHtml5Test < ActionView::TestCase + test 'input should generate a datetime input for datetime attributes' do with_input_for @user, :created_at, :datetime - 1.upto(5) do |i| - assert_select "form select.datetime#user_created_at_#{i}i" + + assert_select 'input[type="datetime"]' + end + + test 'input should generate a datetime select for datetime attributes if HTML5 compatibility is explicitly disabled' do + with_input_for @user, :created_at, :datetime, html5: false + + assert_select 'select.datetime' + end + + test 'input should generate a date input for date attributes' do + with_input_for @user, :born_at, :date + + assert_select 'input[type="date"]' + end + + test 'input should generate a date select for date attributes if HTML5 compatibility is explicitly disabled' do + with_input_for @user, :born_at, :date, html5: false + + assert_select 'select.date' + end + + test 'input should generate a time input for time attributes' do + with_input_for @user, :delivery_time, :time + + assert_select 'input[type="time"]' + end + + test 'input should generate a time select for time attributes if HTML5 compatibility is explicitly disabled' do + with_input_for @user, :delivery_time, :time, html5: false + + assert_select 'select.time' + end + + test 'input should generate required html attribute' do + with_input_for @user, :delivery_time, :time, required: true + assert_select 'input.required' + assert_select 'input[required]' + end + + test 'input should have an aria-required html attribute' do + with_input_for @user, :delivery_time, :time, required: true + assert_select 'input[aria-required=true]' + end +end + +# Tests for datetime, date and time inputs when HTML5 compatibility is enabled in the wrapper. +class DateTimeInputWithoutHtml5Test < ActionView::TestCase + test 'input should generate a datetime select by default for datetime attributes' do + swap_wrapper do + with_input_for @user, :created_at, :datetime + 1.upto(5) do |i| + assert_select "form select.datetime#user_created_at_#{i}i" + end end end test 'input should be able to pass options to datetime select' do - with_input_for @user, :created_at, :datetime, + with_input_for @user, :created_at, :datetime, html5: false, disabled: true, prompt: { year: 'ano', month: 'mês', day: 'dia' } assert_select 'select.datetime[disabled=disabled]' @@ -21,16 +72,26 @@ class DateTimeInputTest < ActionView::TestCase assert_select 'select.datetime option', 'dia' end + test 'input should generate a datetime input for datetime attributes if HTML5 compatibility is explicitly enabled' do + swap_wrapper do + with_input_for @user, :created_at, :datetime, html5: true + + assert_select 'input[type="datetime"]' + end + end + test 'input should generate a date select for date attributes' do - with_input_for @user, :born_at, :date - assert_select 'select.date#user_born_at_1i' - assert_select 'select.date#user_born_at_2i' - assert_select 'select.date#user_born_at_3i' - assert_no_select 'select.date#user_born_at_4i' + swap_wrapper do + with_input_for @user, :born_at, :date + assert_select 'select.date#user_born_at_1i' + assert_select 'select.date#user_born_at_2i' + assert_select 'select.date#user_born_at_3i' + assert_no_select 'select.date#user_born_at_4i' + end end test 'input should be able to pass options to date select' do - with_input_for @user, :born_at, :date, as: :date, + with_input_for @user, :born_at, :date, as: :date, html5: false, disabled: true, prompt: { year: 'ano', month: 'mês', day: 'dia' } assert_select 'select.date[disabled=disabled]' @@ -40,21 +101,31 @@ class DateTimeInputTest < ActionView::TestCase end test 'input should be able to pass :default to date select' do - with_input_for @user, :born_at, :date, default: Date.today + with_input_for @user, :born_at, :date, default: Date.today, html5: false assert_select "select.date option[value=#{Date.today.year}][selected=selected]" end + test 'input should generate a date input for date attributes if HTML5 compatibility is explicitly enabled' do + swap_wrapper do + with_input_for @user, :born_at, :date, html5: true + + assert_select 'input[type="date"]' + end + end + test 'input should generate a time select for time attributes' do - with_input_for @user, :delivery_time, :time - assert_select 'input[type=hidden]#user_delivery_time_1i' - assert_select 'input[type=hidden]#user_delivery_time_2i' - assert_select 'input[type=hidden]#user_delivery_time_3i' - assert_select 'select.time#user_delivery_time_4i' - assert_select 'select.time#user_delivery_time_5i' + swap_wrapper do + with_input_for @user, :delivery_time, :time + assert_select 'input[type=hidden]#user_delivery_time_1i' + assert_select 'input[type=hidden]#user_delivery_time_2i' + assert_select 'input[type=hidden]#user_delivery_time_3i' + assert_select 'select.time#user_delivery_time_4i' + assert_select 'select.time#user_delivery_time_5i' + end end test 'input should be able to pass options to time select' do - with_input_for @user, :delivery_time, :time, required: true, + with_input_for @user, :delivery_time, :time, required: true, html5: false, disabled: true, prompt: { hour: 'hora', minute: 'minuto' } assert_select 'select.time[disabled=disabled]' @@ -62,43 +133,53 @@ class DateTimeInputTest < ActionView::TestCase assert_select 'select.time option', 'minuto' end + test 'input should generate a time input for time attributes if HTML5 compatibility is explicitly enabled' do + swap_wrapper do + with_input_for @user, :delivery_time, :time, html5: true + + assert_select 'input[type="time"]' + end + end + test 'label should use i18n to get target for date input type' do store_translations(:en, date: { order: ['month', 'day', 'year'] }) do - with_input_for :project, :created_at, :date + with_input_for :project, :created_at, :date, html5: false assert_select 'label[for=project_created_at_2i]' end end test 'label should use i18n to get target for datetime input type' do store_translations(:en, date: { order: ['month', 'day', 'year'] }) do - with_input_for :project, :created_at, :datetime + with_input_for :project, :created_at, :datetime, html5: false assert_select 'label[for=project_created_at_2i]' end end test 'label should use order to get target when date input type' do - with_input_for :project, :created_at, :date, order: ['month', 'year', 'day'] + with_input_for :project, :created_at, :date, order: ['month', 'year', 'day'], html5: false assert_select 'label[for=project_created_at_2i]' end test 'label should use order to get target when datetime input type' do - with_input_for :project, :created_at, :datetime, order: ['month', 'year', 'day'] + with_input_for :project, :created_at, :datetime, order: ['month', 'year', 'day'], html5: false assert_select 'label[for=project_created_at_2i]' end test 'label should point to first option when time input type' do - with_input_for :project, :created_at, :time + with_input_for :project, :created_at, :time, html5: false assert_select 'label[for=project_created_at_4i]' end test 'date time input should generate required html attribute' do - with_input_for @user, :delivery_time, :time, required: true + skip + with_input_for @user, :delivery_time, :time, required: true, html5: false assert_select 'select.required' assert_select 'select[required]' end test 'date time input has an aria-required html attribute' do - with_input_for @user, :delivery_time, :time, required: true + skip + with_input_for @user, :delivery_time, :time, required: true, html5: false assert_select 'select.required' assert_select 'select[aria-required=true]' end From 2b1dcd16ba8dafeea41f8af779a02619e2b2ed94 Mon Sep 17 00:00:00 2001 From: Volmer Soares Date: Wed, 13 Nov 2013 15:30:43 -0200 Subject: [PATCH 2/8] Assert `input` tags instead of `select` for datetime attributes. --- test/form_builder/general_test.rb | 10 +++++----- test/inputs/disabled_test.rb | 4 ++-- test/inputs/general_test.rb | 8 ++++---- test/inputs/readonly_test.rb | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/form_builder/general_test.rb b/test/form_builder/general_test.rb index 223732ac..2f780719 100644 --- a/test/form_builder/general_test.rb +++ b/test/form_builder/general_test.rb @@ -158,22 +158,22 @@ class FormBuilderTest < ActionView::TestCase test 'builder should generate date select for date columns' do with_form_for @user, :born_at - assert_select 'form select#user_born_at_1i.date' + assert_select 'form input#user_born_at.date' end test 'builder should generate time select for time columns' do with_form_for @user, :delivery_time - assert_select 'form select#user_delivery_time_4i.time' + assert_select 'form input#user_delivery_time.time' end test 'builder should generate datetime select for datetime columns' do with_form_for @user, :created_at - assert_select 'form select#user_created_at_1i.datetime' + assert_select 'form input#user_created_at.datetime' end test 'builder should generate datetime select for timestamp columns' do with_form_for @user, :updated_at - assert_select 'form select#user_updated_at_1i.datetime' + assert_select 'form input#user_updated_at.datetime' end test 'builder should generate file for file columns' do @@ -406,7 +406,7 @@ class FormBuilderTest < ActionView::TestCase test 'builder should allow overriding input type when object is not present' do with_form_for :project, :created_at, as: :datetime - assert_select 'form select.datetime#project_created_at_1i' + assert_select 'form input.datetime#project_created_at' with_form_for :project, :budget, as: :decimal assert_select 'form input.decimal#project_budget' end diff --git a/test/inputs/disabled_test.rb b/test/inputs/disabled_test.rb index fef3cd36..9db6424b 100644 --- a/test/inputs/disabled_test.rb +++ b/test/inputs/disabled_test.rb @@ -18,12 +18,12 @@ class DisabledTest < ActionView::TestCase test 'date input should be disabled when disabled option is true' do with_input_for @user, :born_at, :date, disabled: true - assert_select 'select.date.disabled[disabled]' + assert_select 'input.date.disabled[disabled]' end test 'datetime input should be disabled when disabled option is true' do with_input_for @user, :created_at, :datetime, disabled: true - assert_select 'select.datetime.disabled[disabled]' + assert_select 'input.datetime.disabled[disabled]' end test 'string input should not be disabled when disabled option is false' do diff --git a/test/inputs/general_test.rb b/test/inputs/general_test.rb index 5b3e3da8..e21a9e1c 100644 --- a/test/inputs/general_test.rb +++ b/test/inputs/general_test.rb @@ -10,9 +10,9 @@ class InputTest < ActionView::TestCase with_input_for @user, :age, :integer assert_select 'input.integer' with_input_for @user, :born_at, :date - assert_select 'select.date' + assert_select 'input.date' with_input_for @user, :created_at, :datetime - assert_select 'select.datetime' + assert_select 'input.datetime' end test 'string input should generate autofocus attribute when autofocus option is true' do @@ -48,12 +48,12 @@ class InputTest < ActionView::TestCase test 'date input should generate autofocus attribute when autofocus option is true' do with_input_for @user, :born_at, :date, autofocus: true - assert_select 'select.date[autofocus]' + assert_select 'input.date[autofocus]' end test 'datetime input should generate autofocus attribute when autofocus option is true' do with_input_for @user, :created_at, :datetime, autofocus: true - assert_select 'select.datetime[autofocus]' + assert_select 'input.datetime[autofocus]' end test 'string input should generate autofocus attribute when autofocus option is false' do diff --git a/test/inputs/readonly_test.rb b/test/inputs/readonly_test.rb index c6f4070a..c99ecc13 100644 --- a/test/inputs/readonly_test.rb +++ b/test/inputs/readonly_test.rb @@ -18,12 +18,12 @@ class ReadonlyTest < ActionView::TestCase test 'date input should generate readonly elements when readonly option is true' do with_input_for @user, :born_at, :date, readonly: true - assert_select 'select.date.readonly[readonly]' + assert_select 'input.date.readonly[readonly]' end test 'datetime input should generate readonly elements when readonly option is true' do with_input_for @user, :created_at, :datetime, readonly: true - assert_select 'select.datetime.readonly[readonly]' + assert_select 'input.datetime.readonly[readonly]' end test 'string input should generate readonly elements when readonly option is false' do From a7c9575a4e524a4349933cc8ce718b05e83dd91b Mon Sep 17 00:00:00 2001 From: Volmer Soares Date: Wed, 13 Nov 2013 16:50:09 -0200 Subject: [PATCH 3/8] Do not assert `required` HTML5 attribute when HTML5 compatibility is disabled. --- test/inputs/datetime_input_test.rb | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/test/inputs/datetime_input_test.rb b/test/inputs/datetime_input_test.rb index 6c388764..bed96d5a 100644 --- a/test/inputs/datetime_input_test.rb +++ b/test/inputs/datetime_input_test.rb @@ -169,18 +169,4 @@ class DateTimeInputWithoutHtml5Test < ActionView::TestCase with_input_for :project, :created_at, :time, html5: false assert_select 'label[for=project_created_at_4i]' end - - test 'date time input should generate required html attribute' do - skip - with_input_for @user, :delivery_time, :time, required: true, html5: false - assert_select 'select.required' - assert_select 'select[required]' - end - - test 'date time input has an aria-required html attribute' do - skip - with_input_for @user, :delivery_time, :time, required: true, html5: false - assert_select 'select.required' - assert_select 'select[aria-required=true]' - end end From f345328b81392b4feb483eb5a6eb992b8152bfd7 Mon Sep 17 00:00:00 2001 From: Volmer Soares Date: Wed, 13 Nov 2013 18:25:41 -0200 Subject: [PATCH 4/8] Add a CHANGELOG entry regarding datetime inputs. --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56620b9b..2788c87a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## master +### enchancements + * Map `datetime`, `date` and `time` input types to their respective HTML5 input tags + when HTML5 compatibility is enabled. To render the classic datetime selects in HTML5 + form wrappers, set the `:html5` option to `false`. [@volmer](https://github.com/volmer) + ### bug fix * Collection input generates `required` attribute if it has `prompt` option. [@nashby](https://github.com/nashby) From 5dff6f29ae2b564db3fa9599303d3c2d6f5f2a92 Mon Sep 17 00:00:00 2001 From: Volmer Soares Date: Fri, 15 Nov 2013 16:46:43 -0200 Subject: [PATCH 5/8] Remove unecessary `enable` call. --- lib/simple_form/inputs/date_time_input.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/simple_form/inputs/date_time_input.rb b/lib/simple_form/inputs/date_time_input.rb index ca40b383..aa8f14e7 100644 --- a/lib/simple_form/inputs/date_time_input.rb +++ b/lib/simple_form/inputs/date_time_input.rb @@ -1,8 +1,6 @@ module SimpleForm module Inputs class DateTimeInput < Base - enable :html5 - def input if use_html5_inputs? @builder.send(:"#{input_type}_field", attribute_name, input_html_options) From 5590f85ee10e97dc9840c47df8a5577726fe80b8 Mon Sep 17 00:00:00 2001 From: Volmer Soares Date: Sat, 16 Nov 2013 02:25:24 -0200 Subject: [PATCH 6/8] Use classic datetime selects unless HTML5 is explicitly enabled. --- lib/simple_form/inputs/date_time_input.rb | 2 +- test/form_builder/general_test.rb | 10 ++++---- test/inputs/datetime_input_test.rb | 28 +++++++++++------------ test/inputs/disabled_test.rb | 4 ++-- test/inputs/general_test.rb | 8 +++---- test/inputs/readonly_test.rb | 4 ++-- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/simple_form/inputs/date_time_input.rb b/lib/simple_form/inputs/date_time_input.rb index aa8f14e7..6c215c7b 100644 --- a/lib/simple_form/inputs/date_time_input.rb +++ b/lib/simple_form/inputs/date_time_input.rb @@ -28,7 +28,7 @@ module SimpleForm if input_options.key?(:html5) input_options[:html5] else - html5? + false end end end diff --git a/test/form_builder/general_test.rb b/test/form_builder/general_test.rb index 2f780719..223732ac 100644 --- a/test/form_builder/general_test.rb +++ b/test/form_builder/general_test.rb @@ -158,22 +158,22 @@ class FormBuilderTest < ActionView::TestCase test 'builder should generate date select for date columns' do with_form_for @user, :born_at - assert_select 'form input#user_born_at.date' + assert_select 'form select#user_born_at_1i.date' end test 'builder should generate time select for time columns' do with_form_for @user, :delivery_time - assert_select 'form input#user_delivery_time.time' + assert_select 'form select#user_delivery_time_4i.time' end test 'builder should generate datetime select for datetime columns' do with_form_for @user, :created_at - assert_select 'form input#user_created_at.datetime' + assert_select 'form select#user_created_at_1i.datetime' end test 'builder should generate datetime select for timestamp columns' do with_form_for @user, :updated_at - assert_select 'form input#user_updated_at.datetime' + assert_select 'form select#user_updated_at_1i.datetime' end test 'builder should generate file for file columns' do @@ -406,7 +406,7 @@ class FormBuilderTest < ActionView::TestCase test 'builder should allow overriding input type when object is not present' do with_form_for :project, :created_at, as: :datetime - assert_select 'form input.datetime#project_created_at' + assert_select 'form select.datetime#project_created_at_1i' with_form_for :project, :budget, as: :decimal assert_select 'form input.decimal#project_budget' end diff --git a/test/inputs/datetime_input_test.rb b/test/inputs/datetime_input_test.rb index bed96d5a..d0528b1b 100644 --- a/test/inputs/datetime_input_test.rb +++ b/test/inputs/datetime_input_test.rb @@ -3,50 +3,50 @@ require 'test_helper' # Tests for datetime, date and time inputs when HTML5 compatibility is enabled in the wrapper. class DateTimeInputWithHtml5Test < ActionView::TestCase - test 'input should generate a datetime input for datetime attributes' do - with_input_for @user, :created_at, :datetime + test 'input should generate a datetime input for datetime attributes if HTML5 compatibility is explicitly enbled' do + with_input_for @user, :created_at, :datetime, html5: true assert_select 'input[type="datetime"]' end - test 'input should generate a datetime select for datetime attributes if HTML5 compatibility is explicitly disabled' do - with_input_for @user, :created_at, :datetime, html5: false + test 'input should generate a datetime select for datetime attributes' do + with_input_for @user, :created_at, :datetime assert_select 'select.datetime' end - test 'input should generate a date input for date attributes' do - with_input_for @user, :born_at, :date + test 'input should generate a date input for date attributes if HTML5 compatibility is explicitly enbled' do + with_input_for @user, :born_at, :date, html5: true assert_select 'input[type="date"]' end - test 'input should generate a date select for date attributes if HTML5 compatibility is explicitly disabled' do - with_input_for @user, :born_at, :date, html5: false + test 'input should generate a date select for date attributes' do + with_input_for @user, :born_at, :date assert_select 'select.date' end - test 'input should generate a time input for time attributes' do - with_input_for @user, :delivery_time, :time + test 'input should generate a time input for time attributes if HTML5 compatibility is explicitly enbled' do + with_input_for @user, :delivery_time, :time, html5: true assert_select 'input[type="time"]' end - test 'input should generate a time select for time attributes if HTML5 compatibility is explicitly disabled' do - with_input_for @user, :delivery_time, :time, html5: false + test 'input should generate a time select for time attributes' do + with_input_for @user, :delivery_time, :time assert_select 'select.time' end test 'input should generate required html attribute' do - with_input_for @user, :delivery_time, :time, required: true + with_input_for @user, :delivery_time, :time, required: true, html5: true assert_select 'input.required' assert_select 'input[required]' end test 'input should have an aria-required html attribute' do - with_input_for @user, :delivery_time, :time, required: true + with_input_for @user, :delivery_time, :time, required: true, html5: true assert_select 'input[aria-required=true]' end end diff --git a/test/inputs/disabled_test.rb b/test/inputs/disabled_test.rb index 9db6424b..fef3cd36 100644 --- a/test/inputs/disabled_test.rb +++ b/test/inputs/disabled_test.rb @@ -18,12 +18,12 @@ class DisabledTest < ActionView::TestCase test 'date input should be disabled when disabled option is true' do with_input_for @user, :born_at, :date, disabled: true - assert_select 'input.date.disabled[disabled]' + assert_select 'select.date.disabled[disabled]' end test 'datetime input should be disabled when disabled option is true' do with_input_for @user, :created_at, :datetime, disabled: true - assert_select 'input.datetime.disabled[disabled]' + assert_select 'select.datetime.disabled[disabled]' end test 'string input should not be disabled when disabled option is false' do diff --git a/test/inputs/general_test.rb b/test/inputs/general_test.rb index e21a9e1c..5b3e3da8 100644 --- a/test/inputs/general_test.rb +++ b/test/inputs/general_test.rb @@ -10,9 +10,9 @@ class InputTest < ActionView::TestCase with_input_for @user, :age, :integer assert_select 'input.integer' with_input_for @user, :born_at, :date - assert_select 'input.date' + assert_select 'select.date' with_input_for @user, :created_at, :datetime - assert_select 'input.datetime' + assert_select 'select.datetime' end test 'string input should generate autofocus attribute when autofocus option is true' do @@ -48,12 +48,12 @@ class InputTest < ActionView::TestCase test 'date input should generate autofocus attribute when autofocus option is true' do with_input_for @user, :born_at, :date, autofocus: true - assert_select 'input.date[autofocus]' + assert_select 'select.date[autofocus]' end test 'datetime input should generate autofocus attribute when autofocus option is true' do with_input_for @user, :created_at, :datetime, autofocus: true - assert_select 'input.datetime[autofocus]' + assert_select 'select.datetime[autofocus]' end test 'string input should generate autofocus attribute when autofocus option is false' do diff --git a/test/inputs/readonly_test.rb b/test/inputs/readonly_test.rb index c99ecc13..c6f4070a 100644 --- a/test/inputs/readonly_test.rb +++ b/test/inputs/readonly_test.rb @@ -18,12 +18,12 @@ class ReadonlyTest < ActionView::TestCase test 'date input should generate readonly elements when readonly option is true' do with_input_for @user, :born_at, :date, readonly: true - assert_select 'input.date.readonly[readonly]' + assert_select 'select.date.readonly[readonly]' end test 'datetime input should generate readonly elements when readonly option is true' do with_input_for @user, :created_at, :datetime, readonly: true - assert_select 'input.datetime.readonly[readonly]' + assert_select 'select.datetime.readonly[readonly]' end test 'string input should generate readonly elements when readonly option is false' do From df4efa2e935962d85a383868b11cca28c9060da7 Mon Sep 17 00:00:00 2001 From: Volmer Soares Date: Mon, 18 Nov 2013 22:23:27 -0200 Subject: [PATCH 7/8] Just `input_options[:html5]` is enough. --- lib/simple_form/inputs/date_time_input.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/simple_form/inputs/date_time_input.rb b/lib/simple_form/inputs/date_time_input.rb index 6c215c7b..0414ad2f 100644 --- a/lib/simple_form/inputs/date_time_input.rb +++ b/lib/simple_form/inputs/date_time_input.rb @@ -25,11 +25,7 @@ module SimpleForm end def use_html5_inputs? - if input_options.key?(:html5) - input_options[:html5] - else - false - end + input_options[:html5] end end end From 476bd96e37ab7f6613744730f637edcb781d73e8 Mon Sep 17 00:00:00 2001 From: Volmer Soares Date: Tue, 26 Nov 2013 20:00:17 -0200 Subject: [PATCH 8/8] Fix mapping table regarding datetime columns. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7b3dbcab..ad62cb4a 100644 --- a/README.md +++ b/README.md @@ -500,9 +500,9 @@ specifying the helper method in the column `Mapping` as the `as:` option. `float` | `input[type=number]` | `float` `decimal` | `input[type=number]` | `decimal` `range` | `input[type=range]` | - - `datetime` | `input[type=datetime]` | `datetime/timestamp` - `date` | `input[type=date]` | `date` - `time` | `input[type=time]` | `time` + `datetime` | `datetime select` | `datetime/timestamp` + `date` | `date select` | `date` + `time` | `time select` | `time` `select` | `select` | `belongs_to`/`has_many`/`has_and_belongs_to_many` associations `radio_buttons` | collection of `input[type=radio]` | `belongs_to` associations `check_boxes` | collection of `input[type=checkbox]` | `has_many`/`has_and_belongs_to_many` associations