We have just migrated from classic UI to touch UI and we are currently using a datepicker field.
The problem we are facing right now is that, our classic UI dialog have stored the value for date in YYYY/MM/DD format and we are trying to save in same format in touch UI using granite/ui/components/coral/foundation/form/datepicker. I have added below properties to the field but still not working. Any quick solution?
fieldDescription="Enter date in this format yyyy/mm/dd"
Solved! Go to Solution.
For the datepicker field,
If you still want the date to be saved like YYYY/MM/DD, alternative it is to save it as String type and not as Date type. This is possible with property named typeHint and value as String.
Retrieval logic should then be handled accordingly.
Related doc for reference:
Is your problem the following?
If this is the case then here is the answer 🙂
The reason for your problem is that providing a custom valueFormat, you are violating the JCR's definition of a date, which you can see here in the spec: https://docs.adobe.com/docs/en/spec/jcr/1.0/18.104.22.168_Date.html
As you can see, a JCR date must follow a certain format, which is not the case for your property. Instead, you should save your date as a String by adding
The type hint (documentation here: https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-po...) tells Sling (which is receiving the POST request to update the JCR when you save a component) to override the default property format and save the value as a "2020/09/11" instead of a Date.
Hope that helps, let me know! 🙂