mirror of
https://github.com/KevinMidboe/nova-map-fields.git
synced 2026-01-18 15:25:49 +00:00
First commit.
This commit is contained in:
40
resources/js/components/FormField.vue
Executable file
40
resources/js/components/FormField.vue
Executable file
@@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<default-field :field="field" :errors="errors">
|
||||
<template slot="field">
|
||||
<component v-if="value" :is="'field-' + field.map.type" :field="field" :edit="true" v-model="value"></component>
|
||||
</template>
|
||||
</default-field>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { FormField, HandlesValidationErrors } from 'laravel-nova'
|
||||
|
||||
export default {
|
||||
mixins: [FormField, HandlesValidationErrors],
|
||||
|
||||
props: ['resourceName', 'resourceId', 'field'],
|
||||
|
||||
methods: {
|
||||
/*
|
||||
* Set the initial, internal value for the field.
|
||||
*/
|
||||
setInitialValue() {
|
||||
this.value = this.field.value || {}
|
||||
},
|
||||
|
||||
/**
|
||||
* Fill the given FormData object with the field's internal value.
|
||||
*/
|
||||
fill(formData) {
|
||||
formData.append(this.field.attribute, JSON.stringify(this.value));
|
||||
},
|
||||
|
||||
/**
|
||||
* Update the field's internal value.
|
||||
*/
|
||||
handleChange(value) {
|
||||
this.value = value
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user