From 88c22aa9279bda549888ce7dcef686383b02c555 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 4 Aug 2021 14:32:58 +0100 Subject: [PATCH] Add default value for boolean field --- .../src/forms/BooleanField.svelte | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/standard-components/src/forms/BooleanField.svelte b/packages/standard-components/src/forms/BooleanField.svelte index 17a3c563bc..1ac602ea40 100644 --- a/packages/standard-components/src/forms/BooleanField.svelte +++ b/packages/standard-components/src/forms/BooleanField.svelte @@ -6,19 +6,33 @@ export let label export let text export let disabled = false + export let defaultValue let fieldState let fieldApi + + const isTruthy = value => { + if (!value) { + return false + } + if (value === true) { + return true + } + if (typeof value === "string" && value.toLowerCase() === "true") { + return true + } + return false + } {#if fieldState}