Add on change action to boolean field
This commit is contained in:
parent
9b56dcfdfe
commit
8e204ae0b8
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue