Time field beside date in dialog for a component | Community
Skip to main content
Level 6
February 5, 2024
Solved

Time field beside date in dialog for a component

  • February 5, 2024
  • 1 reply
  • 1052 views

I have a requirement to show the time field in the dialog form beside the date field. Is this possible and how?

 

 

Currently I have the following configuration in _cq_dialog (time field below the date field):

 

 

 

<dateFrom
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/datepicker"
fieldLabel="Anzeige von"
displayedFormat="DD.MM.YYYY"
name="./dateFrom"
type="date">
<granite:data
jcr:primaryType="nt:unstructured"
allowBulkEdit="{Boolean}true"
cq-msm-lockable="onTime"/>
</dateFrom>
<timeFrom
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/datepicker"
displayedFormat="HH:mm"
displayTimezoneMessage="{Boolean}true"
fieldLabel="Uhrzeit von"
required="{Boolean}false"
name="./timeFrom"
type="time">
<granite:data
jcr:primaryType="nt:unstructured"
allowBulkEdit="{Boolean}true"
cq-msm-lockable="onTime"/>
</timeFrom>
<dateTo
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/datepicker"
fieldLabel="Anzeige bis"
displayedFormat="DD.MM.YYYY"
name="./dateTo"
type="date">
<granite:data
jcr:primaryType="nt:unstructured"
allowBulkEdit="{Boolean}true"
cq-msm-lockable="onTime"/>
</dateTo>
<timeTo
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/datepicker"
displayedFormat="HH:mm"
displayTimezoneMessage="{Boolean}true"
fieldLabel="Uhrzeit von"
required="{Boolean}false"
name="./timeTo"
type="time">
<granite:data
jcr:primaryType="nt:unstructured"
allowBulkEdit="{Boolean}true"
cq-msm-lockable="onTime"/>
</timeTo>
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Raja_Reddy

Hi @anasustic 
Yes, it is possible to show the time field beside the date field in the dialog.

  1. Updated the fieldLabel for the "Uhrzeit bis" (timeTo) field to avoid duplication.
  2. Adjusted the ordering to place the time fields immediately after their respective date fields.

 

 

 

<date jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/datepicker" cq:showOnCreate="{Boolean}true" required="{Boolean}true" displayedFormat="MM-DD-YYYY" fieldLabel="Date" name="./date" type="datetime"> <granite:data jcr:primaryType="nt:unstructured" metaType="datepicker" typeHint="Date"/> </date>

 

 

 

 

1 reply

Raja_Reddy
Community Advisor
Raja_ReddyCommunity AdvisorAccepted solution
Community Advisor
February 5, 2024

Hi @anasustic 
Yes, it is possible to show the time field beside the date field in the dialog.

  1. Updated the fieldLabel for the "Uhrzeit bis" (timeTo) field to avoid duplication.
  2. Adjusted the ordering to place the time fields immediately after their respective date fields.

 

 

 

<date jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/datepicker" cq:showOnCreate="{Boolean}true" required="{Boolean}true" displayedFormat="MM-DD-YYYY" fieldLabel="Date" name="./date" type="datetime"> <granite:data jcr:primaryType="nt:unstructured" metaType="datepicker" typeHint="Date"/> </date>

 

 

 

 

anasusticAuthor
Level 6
February 6, 2024

Thank a lot @raja_reddy for your reply. It works like you described and showed in your picture. I change the displayFormat property so that editors add date&time in the same field which makes the dialog "less busy".

displayedFormat="MM/DD/YYYY HH:mm"