diff --git a/app/helpers/orbit_form_helper.rb b/app/helpers/orbit_form_helper.rb index e7a2555ef..05ffc2e53 100644 --- a/app/helpers/orbit_form_helper.rb +++ b/app/helpers/orbit_form_helper.rb @@ -34,8 +34,8 @@ module OrbitFormHelper def date_picker(object_name, method, options) custom = {} - custom[:format] = 'yyyy-MM-dd' - custom[:value] = display_date(options[:value]) if options[:value] + custom[:format] = options[:format] || 'yyyy/MM' + custom[:value] = format_value(options[:value], custom[:format]) if options[:value] custom[:picker_class] = 'date_picker' custom[:label] = options[:label] || I18n.t('datetime_picker.date.label') custom[:placeholder] = options[:placeholder] || I18n.t('datetime_picker.date.placeholder') @@ -44,8 +44,8 @@ module OrbitFormHelper def default_picker(object_name, method, options) custom = {} - custom[:format] = 'yyyy-MM-dd hh:mm' - custom[:value] = display_date_time(options[:value]) if options[:value] + custom[:format] = options[:format] || 'yyyy/MM/dd hh:mm' + custom[:value] = format_value(options[:value], custom[:format]) if options[:value] custom[:picker_class] = 'default_picker' custom[:label] = options[:label] || I18n.t('datetime_picker.default.label') custom[:placeholder] = options[:placeholder] || I18n.t('datetime_picker.default.placeholder') @@ -54,8 +54,8 @@ module OrbitFormHelper def time_picker(object_name, method, options) custom = {} - custom[:format] = 'hh:mm' - custom[:value] = display_time(options[:value]) if options[:value] + custom[:format] = options[:format] || 'hh:mm' + custom[:value] = format_value(options[:value], custom[:format]) if options[:value] custom[:picker_class] = 'time_picker' custom[:label] = options[:label] || I18n.t('datetime_picker.time.label') custom[:placeholder] = options[:placeholder] || I18n.t('datetime_picker.time.placeholder') @@ -93,6 +93,10 @@ module OrbitFormHelper end end + def format_value(value, format) + value.strftime(format.gsub('yyyy', '%Y').gsub('MM', '%m').gsub('dd', '%d').gsub('hh', '%H').gsub('mm', '%M')) + end + end module Orbit::FormBuilder diff --git a/config/locales/picker.en.yml b/config/locales/picker.en.yml index 999d91959..82121f6ee 100644 --- a/config/locales/picker.en.yml +++ b/config/locales/picker.en.yml @@ -3,10 +3,10 @@ en: datetime_picker: date: label: Date - placeholder: "YYYY-MM-DD" + placeholder: "YYYY/MM/DD" default: label: Date and time - placeholder: "YYYY-MM-DD HH:MM" + placeholder: "YYYY/MM/DD HH:MM" separated: label: Date and time time: diff --git a/config/locales/picker.zh_tw.yml b/config/locales/picker.zh_tw.yml index 1bedaa99e..f3fa6a0ff 100644 --- a/config/locales/picker.zh_tw.yml +++ b/config/locales/picker.zh_tw.yml @@ -3,10 +3,10 @@ zh_tw: datetime_picker: date: label: 日期 - placeholder: "YYYY-MM-DD" + placeholder: "YYYY/MM/DD" default: label: 日期和時間 - placeholder: "YYYY-MM-DD HH:MM" + placeholder: "YYYY/MM/DD HH:MM" separated: label: 日期和時間 time: