Generate a vue form with validation and bulma style, from json
All fields are required and input text by default.
Once submitted an event 'formSubmitted' is emitted on $root with the formName and all values.
Enjoy
yarn add vue-form-json vee-validate bulma @fortawesome/fontawesome-free
// main.js
import VeeValidate from 'vee-validate'
// ...
Vue.use(VeeValidate)
// ...
<template lang="pug">
#app.section
form-json(:formFields="jsonFields",
:formName="'userProfil'")
</template>
<script>
import formJson from 'vue-form-json'
import jsonFields from './../assets/fields'
export default {
name: 'app',
components: {
formJson
},
data: () => ({
jsonFields
}),
mounted () {
this.$root.$on('formSubmitted', values => alert(JSON.stringify(values)))
}
}
</script>
<style lang="stylus">
@require '../node_modules/bulma/css/bulma.min.css'
@require '../node_modules/@fortawesome/fontawesome-free/css/all.min.css'
@require '../node_modules/vue-form-json/dist/vue-form-json.css'
</style>
props: {
formFields: {
type: Array,
required: true
},
formName: {
type: String,
required: true
},
mandatoryAsteriskLegend: {
type: String,
default: '* field required'
},
btnSubmitText: {
type: String,
default: 'Submit'
},
btnResetText: {
type: String,
default: 'Reset'
}
}