-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#469 - fixes example in README, tested with a fresh vue-cli project
* converted to single-quotes (vue-cli default settings) * converted `data` property into a function * added `validateAsync` to `formOptions` to show it is available * added `vfg.css` * added `Vue` import
- Loading branch information
Showing
1 changed file
with
70 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,73 +109,83 @@ If you want the slim down version, here is the changes: | |
</template> | ||
|
||
<script> | ||
import VueFormGenerator from "vue-form-generator"; | ||
import Vue from 'vue' | ||
import VueFormGenerator from 'vue-form-generator' | ||
import 'vue-form-generator/dist/vfg.css' | ||
Vue.use(VueFormGenerator); | ||
Vue.use(VueFormGenerator) | ||
export default { | ||
data: { | ||
model: { | ||
id: 1, | ||
name: "John Doe", | ||
password: "J0hnD03!x4", | ||
skills: ["Javascript", "VueJS"], | ||
email: "[email protected]", | ||
status: true | ||
}, | ||
schema: { | ||
fields: [{ | ||
type: "input", | ||
inputType: "text", | ||
label: "ID (disabled text field)", | ||
model: "id", | ||
readonly: true, | ||
disabled: true | ||
},{ | ||
type: "input", | ||
inputType: "text", | ||
label: "Name", | ||
model: "name", | ||
placeholder: "Your name", | ||
featured: true, | ||
required: true | ||
},{ | ||
type: "input", | ||
inputType: "password", | ||
label: "Password", | ||
model: "password", | ||
min: 6, | ||
required: true, | ||
hint: "Minimum 6 characters", | ||
validator: VueFormGenerator.validators.string | ||
},{ | ||
type: "select", | ||
label: "Skills", | ||
model: "skills", | ||
values: ["Javascript", "VueJS", "CSS3", "HTML5"] | ||
},{ | ||
type: "input", | ||
inputType: "email", | ||
label: "E-mail", | ||
model: "email", | ||
placeholder: "User's e-mail address" | ||
},{ | ||
type: "checkbox", | ||
label: "Status", | ||
model: "status", | ||
default: true | ||
}] | ||
}, | ||
formOptions: { | ||
validateAfterLoad: true, | ||
validateAfterChanged: true | ||
data () { | ||
return { | ||
model: { | ||
id: 1, | ||
name: 'John Doe', | ||
password: 'J0hnD03!x4', | ||
skills: ['Javascript', 'VueJS'], | ||
email: '[email protected]', | ||
status: true | ||
}, | ||
schema: { | ||
fields: [ | ||
{ | ||
type: 'input', | ||
inputType: 'text', | ||
label: 'ID (disabled text field)', | ||
model: 'id', | ||
readonly: true, | ||
disabled: true | ||
}, | ||
{ | ||
type: 'input', | ||
inputType: 'text', | ||
label: 'Name', | ||
model: 'name', | ||
placeholder: 'Your name', | ||
featured: true, | ||
required: true | ||
}, | ||
{ | ||
type: 'input', | ||
inputType: 'password', | ||
label: 'Password', | ||
model: 'password', | ||
min: 6, | ||
required: true, | ||
hint: 'Minimum 6 characters', | ||
validator: VueFormGenerator.validators.string | ||
}, | ||
{ | ||
type: 'select', | ||
label: 'Skills', | ||
model: 'skills', | ||
values: ['Javascript', 'VueJS', 'CSS3', 'HTML5'] | ||
}, | ||
{ | ||
type: 'input', | ||
inputType: 'email', | ||
label: 'E-mail', | ||
model: 'email', | ||
placeholder: 'User\'s e-mail address' | ||
}, | ||
{ | ||
type: 'checkbox', | ||
label: 'Status', | ||
model: 'status', | ||
default: true | ||
} | ||
] | ||
}, | ||
formOptions: { | ||
validateAfterLoad: true, | ||
validateAfterChanged: true, | ||
validateAsync: true | ||
} | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
``` | ||
|
||
Usage in local components | ||
|