Added route and submit button
This commit is contained in:
parent
5e69e52bcd
commit
0fad5304f8
1 changed files with 18 additions and 6 deletions
|
|
@ -1,12 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="uk-form-stacked">
|
<form @submit.prevent="submitForm" class="uk-form-stacked">
|
||||||
|
|
||||||
<div v-for="(field, index) in schema" :key="index">
|
<div v-for="(field, index) in schema" :key="index">
|
||||||
|
|
||||||
<div v-if="Array.isArray(field)" class="uk-grid-small" uk-grid>
|
<div v-if="Array.isArray(field)" class="uk-grid-small" uk-grid>
|
||||||
<div v-for="(subfield, subindex) in field" :key="subindex" class="uk-width-expand">
|
<div v-for="(subfield, subindex) in field" :key="subindex" class="uk-width-expand">
|
||||||
<component
|
<component
|
||||||
:is="subfield.fieldType"
|
:is="subfield.fieldType"
|
||||||
@input="updateForm(subfield.name, $event)"
|
v-model="formData[subfield.name]"
|
||||||
v-bind="subfield">
|
v-bind="subfield">
|
||||||
</component>
|
</component>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -14,12 +14,14 @@
|
||||||
|
|
||||||
<component
|
<component
|
||||||
:is="field.fieldType"
|
:is="field.fieldType"
|
||||||
@input="updateForm(field.name, $event)"
|
v-model="formData[field.name]"
|
||||||
v-bind="field">
|
v-bind="field">
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
<button type="submit" class="uk-button uk-button-primary uk-form-small uk-float-right uk-margin-small uk-width-1-1">Submit</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -47,6 +49,10 @@ export default {
|
||||||
'schema': {
|
'schema': {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
'route': {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -66,7 +72,13 @@ export default {
|
||||||
console.log(`${fieldName}: ${value}`)
|
console.log(`${fieldName}: ${value}`)
|
||||||
this.$set(this.formData, fieldName, value);
|
this.$set(this.formData, fieldName, value);
|
||||||
this.$emit('input', this.formData)
|
this.$emit('input', this.formData)
|
||||||
|
},
|
||||||
|
|
||||||
|
submitForm() {
|
||||||
|
console.log(`Mock-submitting form to ${this.route}:`)
|
||||||
|
console.log(this.formData)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue