Extending the structure field in a plugin


I am trying to define a panel field in a plugin that extends the structure field. My goal is to predefine one field that is a multiselect that queries it’s options from a specific page (for a relation-type connection) and lets the user add fields to the structure in the blueprint. I came pretty far, but now I’m stuck with extending the structure field.
In the moment, the blueprint of my field looks like this:

        label: Works
        type: relation #<--- this is the type i defined, extending the structure field
                label: Work
                type: multiselect
                min: 1
                max: 1
                options: query
                    fetch: site.find('works').childrenAndDrafts
                    text: "{{ page.title }}"
                    value: "{{ page.autoid }}"
          unique: works
        relatedContentType: work
        relatedPage: works
        relatationField: author

I know that the first field inside the structure will always be “foreignKey” of type multiselect with the given options and the query, so i want to move that into the definition of my field. With the help of this by @sts topic i now came so far:

The index.php of my plugin looks like this:

use Kirby\Cms\Form;
    'fields' => function () {
                    return [
                        'foreignKey' => [
                            'type' => "multiselect",
                            'min' => 1,
                            'max' => 1,
                            'options' => "query",
                            'query' => [
                                'fetch' => "site.find('students').childrenAndDrafts",
                                'text' => "{{ page.title }}",
                                'value' => "{{ page.autoid }}"
                'validations' => [
                    'unique' => 'foreignKey',

And my Vue Component like this:


export default {
    props: {
        label: String,
        endpoints: Object
    computed: {
        formFields() {
            var fields = {};
            var field = {};
            fields = {
                foreignKey: {
                    type: "multiselect",
                    min: 1,
                    max: 1,
                    options: "query",
                    query: {
                        fetch: "site.find('students').childrenAndDrafts",
                        text: "{{ page.title }}",
                        value: "{{ page.autoid }}"
                    required: false,
                    icon: "title"
            Object.keys(fields).forEach(name => {
                field = fields[name];
                field.section = this.name;
                field.endpoints = {
                    field: this.endpoints.field + "+" + name,
                    section: this.endpoints.section,
                    model: this.endpoints.model
                fields[name] = field;
            return fields;

<style lang="scss">

But i get this error:

this.options.map is not a function

To be honest I am a bit lost in the way the extending of the structure works, so if anyone could point me in the right direction how to get this working a would be very grateful.