Datepicker brings wrong calendar after filling the field

Asked

Viewed 97 times

2

It happens like this: Mum field date, when it is empty, it brings the datepicker correctly and fills the field in the database format aaaa-mm-dd and saved in this format.
When I edit, when placing the cursor in this field, it brings a different calendar with another date. For example, if I choose 06/03/2017, it saves 2017-03-06 and when I edit it shows a 1911 calendar. Where am I missing? Follow the code:

<script type="text/javascript">

$(function() {
    $(".datepicker").datepicker({
        format: "dd/mm/yyyy",
        language: "pt-BR"
    });
});

...

<td> <%= f.text_field :data_vencimento_real, class: 'datepicker' %></td>
  • I have the same problem using datepicker in Django, the problem is in Javascript and not in Rails

  • The problem is not the saving but the loading of the database, where you must convert the date to the due format before sending to view.

1 answer

-1

Try inserting initial date this way. startDate: "01/01/1930"

e.. <%= f.text_field :birth_date, placeholder: 'dd/mm/yyyy', :class =>"form-control datepicker" %>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.