fix field
This commit is contained in:
parent
dcc7a39a37
commit
b2b34659c6
|
|
@ -101,7 +101,7 @@ export const newField = async (
|
||||||
type: "date",
|
type: "date",
|
||||||
ext__show_label: show ? "y" : "n",
|
ext__show_label: show ? "y" : "n",
|
||||||
ext__required: field.optional ? "n" : "y",
|
ext__required: field.optional ? "n" : "y",
|
||||||
sub_type: "datetime",
|
sub_type: "date",
|
||||||
child: {
|
child: {
|
||||||
childs: [],
|
childs: [],
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ export const generateField = async (
|
||||||
commit: boolean
|
commit: boolean
|
||||||
) => {
|
) => {
|
||||||
let fieldType = getString(data.sub_type.value) as string;
|
let fieldType = getString(data.sub_type.value) as string;
|
||||||
|
|
||||||
let table = getString(data.rel__gen_table.value) as string;
|
let table = getString(data.rel__gen_table.value) as string;
|
||||||
const raw_fields = JSON.parse(data.rel__gen_fields.value) as (
|
const raw_fields = JSON.parse(data.rel__gen_fields.value) as (
|
||||||
| string
|
| string
|
||||||
|
|
|
||||||
|
|
@ -54,28 +54,32 @@ export const formInit = (fm: FMLocal, props: FMProps) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (should_load) {
|
if (should_load) {
|
||||||
const on_load_result = on_load({ fm });
|
if (!on_load) {
|
||||||
let result = undefined;
|
console.error("Form on_load is empty. Please re-generate the form.");
|
||||||
if (
|
|
||||||
typeof on_load_result === "object" &&
|
|
||||||
on_load_result instanceof Promise
|
|
||||||
) {
|
|
||||||
result = await on_load_result;
|
|
||||||
} else {
|
} 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) {
|
if (isEditor) {
|
||||||
const item_id = props.item.id;
|
const item_id = props.item.id;
|
||||||
if (item_id) {
|
if (item_id) {
|
||||||
editorFormData[item_id] = {
|
editorFormData[item_id] = {
|
||||||
data: fm.data,
|
data: fm.data,
|
||||||
on_load: get(props.item, "component.props.on_load.value"),
|
on_load: get(props.item, "component.props.on_load.value"),
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue