Make form always inherit closest datasource
This commit is contained in:
parent
eeb912a4a6
commit
6603e504b4
|
@ -18,16 +18,8 @@
|
||||||
let table
|
let table
|
||||||
let fieldMap = {}
|
let fieldMap = {}
|
||||||
|
|
||||||
// Checks if the closest data context matches the model for this forms
|
// Use the closest data context as the initial form values
|
||||||
// datasource, and use it as the initial form values if so
|
const initialValues = $context[`${$context.closestComponentId}`] || {}
|
||||||
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}`]
|
|
||||||
)
|
|
||||||
|
|
||||||
// Form state contains observable data about the form
|
// Form state contains observable data about the form
|
||||||
const formState = writable({ values: initialValues, errors: {}, valid: true })
|
const formState = writable({ values: initialValues, errors: {}, valid: true })
|
||||||
|
|
Loading…
Reference in New Issue