From 6603e504b432b1c8cb25e38a4ba0b6823285f277 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 16 Feb 2021 13:27:38 +0000 Subject: [PATCH] Make form always inherit closest datasource --- packages/standard-components/src/forms/Form.svelte | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/standard-components/src/forms/Form.svelte b/packages/standard-components/src/forms/Form.svelte index d65c851f43..848248362f 100644 --- a/packages/standard-components/src/forms/Form.svelte +++ b/packages/standard-components/src/forms/Form.svelte @@ -18,16 +18,8 @@ let table let fieldMap = {} - // Checks if the closest data context matches the model for this forms - // datasource, and use it as the initial form values if so - const getInitialValues = context => { - return context && context.tableId === datasource?.tableId ? context : {} - } - - // Use the closest data context as the initial form values if it matches - const initialValues = getInitialValues( - $context[`${$context.closestComponentId}`] - ) + // Use the closest data context as the initial form values + const initialValues = $context[`${$context.closestComponentId}`] || {} // Form state contains observable data about the form const formState = writable({ values: initialValues, errors: {}, valid: true })