TrevorS / bootstrap3-datetimepicker-rails

This gem packages the bootstrap-datetimepicker for the Rails 3.1+ asset pipeline.
MIT License
292 stars 123 forks source link

modifying date picker_pattern breaks field input #55

Open msands opened 7 years ago

msands commented 7 years ago

Good evening, first of all, thanks for a great gem.

First of all, let me start this out by saying I had to modify the files a little to properly reflect how the gem should inherit from each other. I had to do this because there was no way to properly change the date icon separately from the time icon. In it's current form, modifying the icon would change it for both the date AND the time. So, my current file structure is as follows:

https://gist.github.com/msands/c154549cb5f311ec096604f3f22904c9

Now, when attempting to change

  def picker_pattern
    I18n.t('datepicker.pformat', default: 'DD/MM/YYYY')
  end

to

  def picker_pattern
    I18n.t('datepicker.pformat', default: 'MM/DD/YYYY')
  end

any submission of the form stores nil in the database for rails on the date field. Here is my form input in simple_form: = e.input :date, as: :date_picker, label: "Event date", required: true

If I modify the display_patern to the US display of %m/%d/%Y, and leave the picker_patern how it is, everything gets sent to the database correctly. This ONLY breaks when modifying picker_patern.

msands commented 7 years ago

OK, I think I may have figured out the problem.

This block of code

  def date_options
    date_options_base
  end

HAS to be located in the file that has the datepicker.pformat information.

msands commented 7 years ago

Apparently I was wrong. that simple addition does not fix the formatting issue on the displaying of the date.