Files
nocodb/packages/nc-gui/helpers/formInput.ts
2025-05-23 07:01:57 +00:00

20 lines
533 B
TypeScript

export const deepReferenceHelper = (formState: Ref, path: string): any => {
return path.split('.').reduce((acc, key) => (acc ? acc[key] : null), formState.value)
}
export const setFormStateHelper = (formState: Ref, path: string, value: any) => {
// update nested prop in formState
const keys = path.split('.')
const lastKey = keys.pop()
if (!lastKey) return
const target = keys.reduce((acc, key) => {
if (!acc[key]) {
acc[key] = {}
}
return acc[key]
}, formState.value)
target[lastKey] = value
}