Add on change action to boolean field
This commit is contained in:
parent
8b3cf851b8
commit
ede7f684c4
1 changed files with 9 additions and 1 deletions
|
@ -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 a new issue