Closed garmoshka-mo closed 8 years ago
Everyone who uses this control must do something like this (or even more complicated, when wasn't lucky to find some more less fast approach)
<%= text_field_tag nil, @date_end.try(:strftime, '%m/%d/%Y'),
{:'data-provide' => 'datepicker', class: 'form-control'} %>
<%= hidden_field_tag :date_end, @date_end %>
$('[data-provide="datepicker"]')
.on('changeDate', function(e){
$(e.target).next().val(
e.format('yyyy-mm-dd')
);
});
something like this should be embedded to gem
Configuring the default format can be done like this:
https://bootstrap-datepicker.readthedocs.io/en/stable/#configuration
@Nerian default format will worsen user experience (standard rails format 2016-09-21 - convenient for programmers, not other people)
There are many time formats. In order to present the date in the right format, I would suggest that you use the i18n library. You can use it to both parse the input and render the output in the right format.
Control is nice, but it requires nightmare with Date strftime etc.. while working with control. It requires adoption for easy pass Date object to control and receive convenient date value on server (e.g. unix timestamp) without complex conversions (that would be rails style)
related to: https://github.com/eternicode/bootstrap-datepicker/issues/373