From af1654a3c9b19bc7bafb88c6a91fffb21e03a70a Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 16 Feb 2021 15:30:20 +0000 Subject: [PATCH] Ensure form doesn't inherit built in datasources --- packages/standard-components/src/forms/Form.svelte | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/standard-components/src/forms/Form.svelte b/packages/standard-components/src/forms/Form.svelte index 848248362f..54246c6ef0 100644 --- a/packages/standard-components/src/forms/Form.svelte +++ b/packages/standard-components/src/forms/Form.svelte @@ -18,8 +18,16 @@ let table let fieldMap = {} + // Returns the closes data context which isn't a built in context + const getInitialValues = context => { + if (["user", "url"].includes(context.closestComponentId)) { + return {} + } + return context[`${context.closestComponentId}`] || {} + } + // Use the closest data context as the initial form values - const initialValues = $context[`${$context.closestComponentId}`] || {} + const initialValues = getInitialValues($context) // Form state contains observable data about the form const formState = writable({ values: initialValues, errors: {}, valid: true })