fix simple_form deprecations

This commit is contained in:
wvengen 2014-12-10 22:03:17 +01:00
parent 7ac3f54709
commit 12bf2198e5
4 changed files with 19 additions and 16 deletions

View file

@ -5,7 +5,8 @@
# @see http://stackoverflow.com/a/20317763/2866660
# @see https://github.com/einzige/date_time_attribute
class DatePickerTimeInput < SimpleForm::Inputs::StringInput
def input
def input(wrapper_options)
options = merge_wrapper_options(input_html_options, wrapper_options)
# Date format must match datepicker's, see app/assets/application.js .
# And for html5 inputs, match RFC3339, see http://dev.w3.org/html5/markup/datatypes.html#form.data.date .
# In the future, use html5 date&time inputs. This needs modernizr or equiv. to avoid
@ -13,8 +14,8 @@ class DatePickerTimeInput < SimpleForm::Inputs::StringInput
value = @builder.object.send attribute_name
date_options = {as: :string, class: 'input-small datepicker'}
time_options = {as: :string, class: 'input-mini'}
@builder.input_field("#{attribute_name}_date_value", input_html_options.merge(date_options)) + ' ' +
@builder.input_field("#{attribute_name}_time_value", input_html_options.merge(time_options))
@builder.input_field("#{attribute_name}_date_value", options.merge(date_options)) + ' ' +
@builder.input_field("#{attribute_name}_time_value", options.merge(time_options))
# time_select requires a date_select
#@builder.time_select("#{attribute_name}_time", {ignore_date: true}, input_html_options.merge(time_options))
end