Add on change action to boolean field

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

View File

@ -9,6 +9,7 @@
export let size
export let validation
export let defaultValue
export let onChange
let fieldState
let fieldApi
@ -25,6 +26,13 @@
}
return false
}
const handleChange = e => {
fieldApi.setValue(e.detail)
if (onChange) {
onChange({ value: e.detail })
}
}
</script>
<Field
@ -44,8 +52,8 @@
error={fieldState.error}
id={fieldState.fieldId}
{size}
on:change={e => fieldApi.setValue(e.detail)}
{text}
on:change={handleChange}
/>
{/if}
</Field>