Skip to content

Initial value ignores the format specifiedΒ #45

@vitobotta

Description

@vitobotta

Hi! Thanks for this controller. Everything works for me apart from the formatting of the initial value. I am using the controller like this:

        <%= f.text_field :published_at,
          class: "form-text",
          data: {
            controller: "datetime-picker",
            datetime_picker_enable_time: true,
            datetime_picker_alt_format: "D, F j Y at h:i K",
            datetime_picker_date_format: "D, F j Y at h:i K",
            datetime_picker_time_24hr: false,
            datetime_picker_min_date: 10.years.ago
          } %>

When I select a date/time, it is formatted as expected in the text field. However when the flatpikr is first rendered, the current value of published_at is displayed as "2020-01-27 21:06:07 +0200" in the input field. How can I ensure that the initial value is formatted as "D, F j Y at h:i K" too? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions