Hi All,
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?
<preselectedDate
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/datepicker"
fieldDescription="Enter date in this format yyyy/mm/dd"
fieldLabel="Pre-selected date"
name="./preselectedDate"
required="{Boolean}false"
displayedFormat="YYYY/MM/DD"
valueFormat="YYYY/MM/DD"
storedValue="YYYY/MM/DD"
type="date"/>
Solved! Go to Solution.
Please go through this wonderful blog
https://blogs.perficient.com/2018/10/18/a-way-to-handle-dates-in-aem/
Hi @ashishkhadpe,
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:
Views
Replies
Total Likes
In the below documentation, it mentions the "displayedFormat" property as "displayFormat".
Views
Replies
Total Likes
Hi @ashishkhadpe,
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/6.2.5.1_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
typeHint="String"
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!
Please go through this wonderful blog
https://blogs.perficient.com/2018/10/18/a-way-to-handle-dates-in-aem/
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies