I use Vuetify in the frontend and Laravel in the backend. I'm trying to create a dynamic table where the user can set the column names himself. Therefore I created a form with a loop for 2 fields:
<template>
<div>
<v-card>
<v-card-text>
<v-row v-for="n in numTextFields" align="center">
<v-col> <h3> Text {{ n }} </h3> </v-col>
<v-col> <v-text-field label="Bezeichnung" v-model="form.text.name[n]" > </v-text-field> </v-col>
<v-col> <v-switch label="Erforderlich" value="1" v-model="form.text.required[n]"></v-switch></v-col>
<v-col>Info</v-col>
</v-row>
{{ form }}
</v-card-text>
</v-card>
</div>
</template>
<script>
export default {
name: "SmartTableColumnSetting",
data() {
return {
numTextFields: 10,
form: {
text: {
name: [],
required: []
}
}
}
},
}
</script>
This gives the following example:
{ "text": { "name": [ null, "Input Text 1", null, null, null, null, null, "Input Text 7" ], "required": [ null, null, null, null, "1", null, "1" ] } }
I'd like to have:
{"text": {
"type_1 :{
text: "Input Text 1"
required: 1
},
"type_2 :{
text: "Input Text 2"
required: 2
},
//and so on till 10
}
Is this possible?
Or do i need to change the values in the backend?
What is the right setup?