mirror of
https://github.com/frappe/books.git
synced 2024-11-10 15:50:56 +00:00
Form
- defaultValues prop to set initial values in a form
This commit is contained in:
parent
5375f21d30
commit
edc04e7522
@ -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;
|
||||
|
@ -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]"
|
||||
|
Loading…
Reference in New Issue
Block a user