Try our conversational search powered by Generative AI!

DateTime editor issues using "date-only" widget


We have a couple of pages containing required non-nullable DateTime properties.

These properties are supposed to be "date-only", so we also use a custom EditorDescriptor for these:

They are also initialized to todays date to get the datepicker at todays date.

As they are required, they need to be set at creation.
But in the new page form these fields starts out with an input value of "0001-01-01", and a hidden value of "2001-01-01"?

(By the way, the input gets updated to the hidden value as soon as ju interact with the input.)

The issue goes away using the default editor; the input comes up empty and the datepicker is at todays date. But then the datepicker includes the time.

Also, any non-required nullable DateTime fields works as expected even with the DateTextBox.

What could cause this issue?

As far as I know there isn't any other modifications in script or rendering done, but if there are, where should I be looking?


It seems the default DateTimeEditorDescriptor uses a custom Episerver widget, "epi/shell/widget/DateTimeSelectorDropDown". Appearantly it handles empty/null/default values better.

No clue if there is a way to configure it to disable the time part, but solved it using the Dojo-variant and setting the inital value to null when property type is non-nullable and is default value.

Edited, Feb 01, 2024 13:51

Maybe you could try with

You can have the model property be of either string, DateTime or DateTime? type:

[ClientEditor(ClientEditingClass = "alloy/Editors/DateEditor")]
public virtual string CustomDateStr { get; set; }
[ClientEditor(ClientEditingClass = "alloy/Editors/DateEditor")]
public virtual DateTime CustomDate1 { get; set; }
[ClientEditor(ClientEditingClass = "alloy/Editors/DateEditor")]
public virtual DateTime? CustomDate2 { get; set; }
Feb 03, 2024 12:24

Thank you, and yes, seems like the more "proper" solution. I will probablt change it to use this at some time. Thanks! 🙂

But it has to be said that it's a bit of a faff to have to add yet more script for such a small change. Would be nice if the editor could just be configured somehow. 🙂

Feb 05, 2024 8:34
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.