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:
parent
387688cebb
commit
9f4f2828ca
@ -92,4 +92,5 @@ export type RawCustomField = {
|
||||
options?: string;
|
||||
target?: string;
|
||||
references?: string;
|
||||
default?: string;
|
||||
};
|
||||
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user