mirror of
https://github.com/frappe/books.git
synced 2024-12-26 12:28:12 +00:00
feat: Allow default to be a function
This commit is contained in:
parent
8158dade1d
commit
613e5d6a5f
@ -111,8 +111,12 @@ module.exports = class BaseDocument extends Observable {
|
|||||||
defaultValue = [];
|
defaultValue = [];
|
||||||
}
|
}
|
||||||
if (field.default) {
|
if (field.default) {
|
||||||
|
if (typeof field.default === 'function') {
|
||||||
|
defaultValue = field.default(this);
|
||||||
|
} else {
|
||||||
defaultValue = field.default;
|
defaultValue = field.default;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this[field.fieldname] = defaultValue;
|
this[field.fieldname] = defaultValue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user