-1

Have a good day. I'm searching the way to set date from edit view in my app and only shows the current date.

I'm using bootstrap datetimepicker like this:

$('.datepicker').datetimepicker(
{
    format: 'DD/MM/YYYY',
    locale: 'es',
    icons: {
        time: "fas fa-clock",
        date: "fas fa-calendar-alt",
        up: "fas fa-arrow-up",
        down: "fas fa-arrow-down",
        previous: "fas fa-chevron-left",
        next: "fas fa-chevron-right"
    },
    defaultDate: null,
    daysOfWeekDisabled: [0, 6]
});

and in my form I've implemented as:

@Html.EditorFor(model => model.ApplyDate, new { htmlAttributes = new { @class = "form-control datepicker", placeholder = "dd/mm/yyyy", tabindex = "5", maxlength = "10", required = "", @Value = Model.ApplyDate } })

but not getting any good results. Only current date is set.

DatePicker with current date, not Model's date

Thanks.

  • You never set the `value` attribute when using the `HtmlHelper` methods - the method already correctly sets it using values from `ModelState` or the value of the property as applicable. –  May 16 '18 at 22:44
  • If I take off the "@Value" attribute, happens the same thing :( – Ilich Morales May 17 '18 at 15:23

1 Answers1

0

I've just realized that my problem setting default date was cause I've used the disabled dates property:

daysOfWeekDisabled: [0, 6]

Once I've take off that part, my problem was solved. Hope to help someone