Add on change action to datetime field

This commit is contained in:
Andrew Kingston 2022-04-14 09:46:46 +01:00
parent 8e204ae0b8
commit 3b71c40570
1 changed files with 9 additions and 1 deletions

View File

@ -10,9 +10,17 @@
export let timeOnly = false export let timeOnly = false
export let validation export let validation
export let defaultValue export let defaultValue
export let onChange
let fieldState let fieldState
let fieldApi let fieldApi
const handleChange = e => {
fieldApi.setValue(e.detail)
if (onChange) {
onChange({ value: e.detail })
}
}
</script> </script>
<Field <Field
@ -28,7 +36,7 @@
{#if fieldState} {#if fieldState}
<CoreDatePicker <CoreDatePicker
value={fieldState.value} value={fieldState.value}
on:change={e => fieldApi.setValue(e.detail)} on:change={handleChange}
disabled={fieldState.disabled} disabled={fieldState.disabled}
error={fieldState.error} error={fieldState.error}
id={fieldState.fieldId} id={fieldState.fieldId}