Skip to content

Commit d008869

Browse files
committed
remove .sync
add options prop to abstractField remove beforeMount
1 parent b4dc972 commit d008869

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed

dev/grouping/app.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template lang="html">
22
<form>
3-
<vue-form-generator :schema="schema" :model="model" :options="formOptions"></vue-form-generator>
3+
<vue-form-generator :schema="schema" :model="model" :options="formOptions" tag="section"></vue-form-generator>
44
<pre>{{ model }}</pre>
55
</form>
66
</template>

src/fields/abstractField.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default {
1717
props: [
1818
"model",
1919
"schema",
20+
"options",
2021
"disabled"
2122
],
2223

@@ -163,14 +164,15 @@ export default {
163164
},
164165

165166
getFieldID(schema) {
167+
const idPrefix = this.options && this.options.fieldIdPrefix ? this.options.fieldIdPrefix : "";
166168
// Try to get a reasonable default id from the schema,
167169
// then slugify it.
168170
if (typeof schema.id !== "undefined") {
169171
// If an ID's been explicitly set, use it unchanged
170-
return schema.idPrefix + schema.id;
172+
return idPrefix + schema.id;
171173
} else {
172174
// Return the slugified version of either:
173-
return schema.idPrefix + (schema.inputName || schema.label || schema.model)
175+
return idPrefix + (schema.inputName || schema.label || schema.model)
174176
// NB: This is a very simple, conservative, slugify function,
175177
// avoiding extra dependencies.
176178
.toString()

src/formGenerator.vue

+2-18
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ div.vue-form-generator(v-if='schema != null')
99
i.icon
1010
.helpText(v-html='field.help')
1111
.field-wrap
12-
component(:is='getFieldType(field)', :disabled='fieldDisabled(field)', :model='model', :schema.sync='field', @model-updated='modelUpdated', @validated="onFieldValidated")
12+
component(:is='getFieldType(field)', :disabled='fieldDisabled(field)', :model='model', :schema='field', :options='options', @model-updated='modelUpdated', @validated="onFieldValidated")
1313
.buttons(v-if='buttonVisibility(field)')
1414
button(v-for='btn in field.buttons', @click='buttonClickHandler(btn, field)', :class='btn.classes') {{ btn.label }}
1515
.hint(v-if='field.hint') {{ field.hint }}
@@ -27,7 +27,7 @@ div.vue-form-generator(v-if='schema != null')
2727
i.icon
2828
.helpText(v-html='field.help')
2929
.field-wrap
30-
component(:is='getFieldType(field)', :disabled='fieldDisabled(field)', :model='model', :schema.sync='field', @model-updated='modelUpdated', @validated="onFieldValidated")
30+
component(:is='getFieldType(field)', :disabled='fieldDisabled(field)', :model='model', :schema='field', :options='options',@model-updated='modelUpdated', @validated="onFieldValidated")
3131
.buttons(v-if='buttonVisibility(field)')
3232
button(v-for='btn in field.buttons', @click='buttonClickHandler(btn, field)', :class='btn.classes') {{ btn.label }}
3333
.hint(v-if='field.hint') {{ field.hint }}
@@ -150,22 +150,6 @@ div.vue-form-generator(v-if='schema != null')
150150
}
151151
},
152152
153-
beforeMount() {
154-
// Add idPrefix to fields if fieldIdPrefix is set
155-
if ("groups" in this.schema) {
156-
for (let group of this.schema.groups) {
157-
for (let field of group.fields) {
158-
field.idPrefix = this.options.fieldIdPrefix || "";
159-
}
160-
}
161-
}
162-
if ("fields" in this.schema) {
163-
for (let field of this.schema.fields) {
164-
field.idPrefix = this.options.fieldIdPrefix || "";
165-
}
166-
}
167-
},
168-
169153
mounted() {
170154
this.$nextTick(() => {
171155
if (this.model) {

0 commit comments

Comments
 (0)