0

In Adobe AEM, I have a CQ dialog (using Granite UI) that has a datepicker inside of it. It looks like this when viewed in the CQ dialog:

enter image description here

The problem occurs whenever I set a date, and save the contents of the dialog:

enter image description here

When I do this, I can't set the date property back to blank again. If I open the dialog and remove the date inside of this field and click save, the property still stays there.

This is an except of my cq dialog's content.xml file which contains the datepicker:

        <startdate
            jcr:primaryType="nt:unstructured"
            sling:resourceType="granite/ui/components/foundation/form/datepicker"
            displayedFormat="YYYY-MM-DD"
            emptyText="YYYY-MM-DD"
            fieldDescription="If limited by a start date, add a start date value. (YYYY-MM-DD)"
            fieldLabel="Start Date"
            name="./startdate"
            storedFormat="YYYY-MM-DD"/>

Why doesn't it save the property when I set it to blank and how do I fix it?

---------EDIT----------

I found that even if I don't put the delete suffixes as @nateyolles places in his answer, the dialog does delete the dates when it is in full-screen mode. It still does not work when the cq dialog is NOT in full screen mode. Either way, I'm sure that this is a bug in AEM.

idungotnosn
  • 2,001
  • 4
  • 29
  • 36

3 Answers3

1

Use the Sling Post Servlet's Delete Suffix. See the Apache Sling doc.

<startdate
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/foundation/form/datepicker"
    displayedFormat="YYYY-MM-DD"
    emptyText="YYYY-MM-DD"
    fieldDescription="If limited by a start date, add a start date value. (YYYY-MM-DD)"
    fieldLabel="Start Date"
    name="./startdate"
    storedFormat="YYYY-MM-DD"/>
<startdateType
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/foundation/form/hidden"
    name="./startdate@Delete"
    value="this text is ignored"/>
nateyolles
  • 1,851
  • 5
  • 17
  • 23
  • This was actually my first guess. Here's something weird: this works correctly if the CQ dialog takes up the whole screen. If the CQ dialog does not take up the whole browser screen, this doesn't actually work. Any ideas what's happening? – idungotnosn May 02 '16 at 20:23
1

As @nateyolles answer. You should open browser console and network tab when you submit the dialog in order to see any form's value that the dialog is transferring to server.

Ha Doan
  • 135
  • 1
  • 11
0

You can also use the date picker from coral ui : granite/ui/components/coral/foundation/form/datepicker

I've seen the issue with the old foundation components and the new coral ui one fixes that issue.