From 24a5b657bccb45da85daac20ca57160a9c8fca54 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 28 Jan 2021 19:41:46 +0000 Subject: [PATCH] Add date field validation --- .../src/forms/DateTimeField.svelte | 15 +++++---- .../src/forms/validation.js | 32 +++++++++++++++++-- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/packages/standard-components/src/forms/DateTimeField.svelte b/packages/standard-components/src/forms/DateTimeField.svelte index 3245ce7662..348a92c20a 100644 --- a/packages/standard-components/src/forms/DateTimeField.svelte +++ b/packages/standard-components/src/forms/DateTimeField.svelte @@ -12,23 +12,24 @@ let fieldApi let value $: fieldApi?.setValue(value) + $: flatpickrOptions = { + element: `#${$fieldState?.id}-wrapper`, + enableTime: true, + altInput: true, + altFormat: "F j Y, H:i", + } const handleChange = event => { const [fullDate] = event.detail value = fullDate } - - const formatDate = dateString => { - const date = new Date(dateString) - return date.toDateString() - } {#if fieldState}
+ value={$fieldState.value} />