AI OnAI Off
Maybe you could try with https://gregwiechec.com/2023/12/date-property/
You can have the model property be of either string, DateTime or DateTime? type:
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. 🙂
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?
Update:
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.