2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 10:58:59 +00:00

fix: isRequired handling

- add support for default value in fields
This commit is contained in:
18alantom 2023-09-18 15:21:56 +05:30
parent 387688cebb
commit 9f4f2828ca
4 changed files with 17 additions and 0 deletions

View File

@ -92,4 +92,5 @@ export type RawCustomField = {
options?: string;
target?: string;
references?: string;
default?: string;
};

View File

@ -150,5 +150,6 @@ export class CustomField extends Doc {
this.fieldtype === 'Select' || this.fieldtype === 'AutoComplete',
target: () => this.fieldtype === 'Link' || this.fieldtype === 'Table',
references: () => this.fieldtype === 'DynamicLink',
default: () => !!this.isRequired,
};
}

View File

@ -94,6 +94,11 @@
"fieldtype": "Check",
"default": false
},
{
"fieldname": "default",
"label": "Default",
"fieldtype": "Data"
},
{
"fieldname": "section",
"label": "Form Section",
@ -128,6 +133,7 @@
"fieldname",
"fieldtype",
"isRequired",
"default",
"options",
"target",
"references",

View File

@ -296,6 +296,7 @@ function getFieldMapFromRawCustomFields(
section,
tab,
options: rawOptions,
default: defaultValue,
target,
references,
}
@ -343,6 +344,14 @@ function getFieldMapFromRawCustomFields(
(field as DynamicLinkField).references = references;
}
if (field.required && defaultValue != null) {
field.default = defaultValue;
}
if (field.required && field.default == null) {
field.required = false;
}
map[parent].push(field);
return map;
},