Invalid date with date string template transformations

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?



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}} - {{ | 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' },
  }, ...

Hi there! Thanks for your interest in Netlify CMS. Looks like you posted your question a little while ago, but that you haven’t received a solution yet. Here’s where you might get more help: - the site houses our extensive documentation that likely contains helpful information to get you back on track.

netlify cms slack - join our friendly slack channel and chat with other cms pros to get the help you need.

GitHub Issues - think you’ve found a bug, or would like to make a feature request? Make your voice heard here. Netlify CMS is open source - PRs and other contributions are also welcome!

Stack Overflow Check StackOverflow for questions tagged “Netlify CMS” if you don’t get an answer in the Slack or the GH issues. StackOverflow reaches a worldwide audience of knowledgeable people.

Your question will be left open here for anyone to comment - but we encourage you to check out the above resources if you are still looking for a solution!