Skip to content

Commit e61824a

Browse files
committed
support custom fields & example #62
1 parent bccc910 commit e61824a

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

dev/app.vue

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
import { users } from "./data";
4040
import { filters } from "./utils";
4141
42+
// Test custom field
43+
import FieldAwesome from "./fieldAwesome.vue";
44+
Vue.component("fieldAwesome", FieldAwesome);
45+
4246
import {each, isFunction, cloneDeep, merge} from 'lodash';
4347
4448
Vue.use(VueFormGenerator);

dev/fieldAwesome.vue

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<template lang="jade">
2+
input.form-control(type="text", v-model="value", :maxlength="schema.max", :readonly="schema.readonly", :disabled="disabled", :placeholder="schema.placeholder")
3+
</template>
4+
5+
<script>
6+
import VueFormGenerator from "../src";
7+
8+
console.log(VueFormGenerator);
9+
export default {
10+
mixins: [ VueFormGenerator.abstractField ]
11+
};
12+
13+
</script>
14+
15+
<style lang="sass" scoped>
16+
input {
17+
background-color: lighten(blue, 40%) !important;
18+
font-weight: bold;
19+
}
20+
</style>

dev/schema.js

+4
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ module.exports = {
179179
label: "E-mail (email field)",
180180
model: "email",
181181
placeholder: "User's e-mail address"
182+
}, {
183+
type: "awesome",
184+
label: "Awesome (custom field)",
185+
model: "userName"
182186
}, {
183187
type: "googleAddress",
184188
label: "Location (googleAddress)",

src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = {
22
component: require("./formGenerator.vue"),
33
schema: require("./utils/schema.js"),
44
validators: require("./utils/validators.js"),
5+
abstractField: require("./fields/abstractField").default,
56

67
install(Vue) {
78
Vue.component("VueFormGenerator", module.exports.component);

0 commit comments

Comments
 (0)