fix field

This commit is contained in:
rizky 2024-07-30 20:06:14 -07:00
parent dcc7a39a37
commit b2b34659c6
3 changed files with 24 additions and 19 deletions

View File

@ -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: [],
},

View File

@ -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

View File

@ -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"),
};
}
}
}
}