diff --git a/comps/form/gen/fields.ts b/comps/form/gen/fields.ts index c2feb30..1c5be06 100755 --- a/comps/form/gen/fields.ts +++ b/comps/form/gen/fields.ts @@ -101,7 +101,7 @@ export const newField = async ( type: "date", ext__show_label: show ? "y" : "n", ext__required: field.optional ? "n" : "y", - sub_type: "datetime", + sub_type: "date", child: { childs: [], }, diff --git a/comps/form/gen/gen-field.ts b/comps/form/gen/gen-field.ts index fe9b7ca..4631471 100755 --- a/comps/form/gen/gen-field.ts +++ b/comps/form/gen/gen-field.ts @@ -12,6 +12,7 @@ export const generateField = async ( commit: boolean ) => { let fieldType = getString(data.sub_type.value) as string; + let table = getString(data.rel__gen_table.value) as string; const raw_fields = JSON.parse(data.rel__gen_fields.value) as ( | string diff --git a/comps/form/utils/init.tsx b/comps/form/utils/init.tsx index a17b01e..b1baec0 100755 --- a/comps/form/utils/init.tsx +++ b/comps/form/utils/init.tsx @@ -54,28 +54,32 @@ export const formInit = (fm: FMLocal, props: FMProps) => { } } if (should_load) { - const on_load_result = on_load({ fm }); - let result = undefined; - if ( - typeof on_load_result === "object" && - on_load_result instanceof Promise - ) { - result = await on_load_result; + if (!on_load) { + console.error("Form on_load is empty. Please re-generate the form."); } else { - result = on_load_result; - } + const on_load_result = on_load({ fm }); + let result = undefined; + if ( + typeof on_load_result === "object" && + on_load_result instanceof Promise + ) { + result = await on_load_result; + } else { + result = on_load_result; + } - fm.data = result; + fm.data = result; - if (result === undefined) fm.data = {}; + if (result === undefined) fm.data = {}; - if (isEditor) { - const item_id = props.item.id; - if (item_id) { - editorFormData[item_id] = { - data: fm.data, - on_load: get(props.item, "component.props.on_load.value"), - }; + if (isEditor) { + const item_id = props.item.id; + if (item_id) { + editorFormData[item_id] = { + data: fm.data, + on_load: get(props.item, "component.props.on_load.value"), + }; + } } } }