2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 15:50:56 +00:00
- defaultValues prop to set initial values in a form
This commit is contained in:
Faris Ansari 2018-07-09 22:05:43 +05:30
parent 5375f21d30
commit edc04e7522
2 changed files with 9 additions and 1 deletions

View File

@ -28,7 +28,7 @@ import { _ } from 'frappejs/utils';
export default {
name: 'Form',
props: ['doctype', 'name'],
props: ['doctype', 'name', 'defaultValues'],
components: {
FormActions,
FormLayout
@ -70,6 +70,13 @@ export default {
this.doc.set('name', '');
}
if (this.defaultValues) {
for (let fieldname in this.defaultValues) {
const value = this.defaultValues[fieldname];
this.doc.set(fieldname, value);
}
}
this.docLoaded = true;
} catch(e) {
this.notFound = true;

View File

@ -18,6 +18,7 @@
<div v-if="!layout">
<frappe-control
v-for="docfield in fields"
v-if="!docfield.hidden"
:key="docfield.fieldname"
:docfield="docfield"
:value="$data[docfield.fieldname]"