Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit 1a539d3

Browse files
committed
added default field name
1 parent e761901 commit 1a539d3

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

dist/vue-form.common.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,13 @@ function Fields (Vue) {
217217
}
218218

219219
each(_extends({}, Vue.fields, fields), function (type, name) {
220+
220221
if (isString(type)) {
221-
type = Vue.extend({ extends: Field, template: type });
222-
} else if (isObject(type)) {
222+
type = { template: type };
223+
}
224+
225+
if (isObject(type)) {
226+
type.name = type.name || 'field-' + name;
223227
type = Vue.extend(Field).extend(type);
224228
}
225229

dist/vue-form.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,13 @@
221221
}
222222

223223
each(_extends({}, Vue.fields, fields), function (type, name) {
224+
224225
if (isString(type)) {
225-
type = Vue.extend({ extends: Field, template: type });
226-
} else if (isObject(type)) {
226+
type = { template: type };
227+
}
228+
229+
if (isObject(type)) {
230+
type.name = type.name || 'field-' + name;
227231
type = Vue.extend(Field).extend(type);
228232
}
229233

dist/vue-form.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/form.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ <h1>Form</h1>
8888

8989
customFields: {
9090

91-
mixins: [Vue.fields],
91+
extends: Vue.component('fields'),
9292

9393
template: `<div>
9494

src/fields.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ export default function (Vue) {
3333
}
3434

3535
each(Object.assign({}, Vue.fields, fields), (type, name) => {
36+
3637
if (isString(type)) {
37-
type = Vue.extend({extends: Field, template: type});
38-
} else if (isObject(type)) {
38+
type = {template: type};
39+
}
40+
41+
if (isObject(type)) {
42+
type.name = type.name || `field-${name}`;
3943
type = Vue.extend(Field).extend(type);
4044
}
4145

0 commit comments

Comments
 (0)