Hi all,
i am doing a Section-Plugin, which instantly creates a Message-Page from Site-Level.
That already works.
Beside other fields, i need to add an Image-Upload, which upload an image into the created page and assign it to a files-field. Unfortenetly i don’t know how to add the endpoints-object to the k-files-field
. I can’t really find examples/infos for that.
Would be nice, if someone can point me to how that has to be done.
Here is a simplified example of the plugin/code.
export default {
data() {
return {
headline: '',
title: '',
files: [],
}
},
created() {
this.load().then(response => {
this.headline = response.headline;
});
},
methods: {
create() {
let content = {
title: this.title
};
this.$api
.post('pages/messages/children', { slug: this.title, template: 'message', content: content })
.then(response => {
console.log('page created')
})
.catch(error => {
console.log('error', error)
});
},
}
};
<template>
<section class="k-links-section">
<fieldset class="k-fieldset">
<k-grid>
<k-column width="1/1">
<k-headline-field :label="headline" numbered="true" />
</k-column>
<k-column width="1/1">
<k-text-field v-model="title" name="title" label="Title/Slug" />
</k-column>
<k-column width="1/1">
<k-files-field v-model="files" :max="1" name="files" label="Files"
:uploads="{'accept':'*'}"
type="files"
size="large"
help="Helptext"
layout="cards"
/>
</k-column>
<k-column width="1/4">
<k-button class="btn-create" icon="add" theme="none" @click="create()" type="submit">Create</k-button>
</k-column>
</k-grid>
</fieldset>
</section>
</template>
Thx!!