Hello Everyone, I’m creating my CMS configuration file and I’m having a problem with string template transformations.
I created a collection of events and in it I have two datetime fields that are not mandatory, so the user may or may not fill them. In this collection I have a summary that brings the event title and the datetime with string template transformations.
My problem is that when the user does not select a datetime, the string template transformations returns “Invalid date” in the summary, and I would not like this to appear
is there any way for me to not display “Invalid date” when the user does not select a date?
Screenshot
CMS configuration
load_config_file: false,
site_url: location.origin,
logo_url: `${location.origin}/SmallLogo.svg`,
show_preview_links: false,
editor: {
preview: false,
},
publish_mode: cmsRole.viewWorkFlow,
media_library: {
name: 'disabled',
},
collections: [
{
label: 'Events & Recordings',
name: 'event',
summary: `{{title}} - {{fields.day | date('MM/DD/YYYY')}} - {{fields.end | date('MM/DD/YYYY')}}`,
folder: cmsCollectionFolder('event'),
create: cmsRole.canCreate,
delete: cmsRole.canDelete,
publish: cmsRole.canPublish,
extension: 'json',
slug: `{{year}}-{{month}}-{{day}}-{{slug}}`,
fields: [
{
label: 'Title',
name: 'title',
widget: 'string',
pattern: ['.{5,}', 'Must have at least 5 characters'],
},
{
label: 'Place',
name: 'place',
widget: 'select',
options: [
{ label: 'Virtual', value: 'Virtual' },
{ label: 'Local', value: 'Local' },
],
},
{ label: 'Start Event', name: 'day', widget: 'datetime', default: '', time_format: false, required: false },
{ label: 'End Event', name: 'end', widget: 'datetime', default: '', time_format: false, required: false },
{ label: 'Link', name: 'link', widget: 'string' },
],
}, ...