I'm trying to generate some input text fields (v-text-field) and render them in which works fine until this point.
Reference JSON
{
"documentAttributes" : {
"documentNumber" : "textField",
"issueDate" : "dateField",
"issuingAuthority" : "textField",
"dynamicProperties" : {
"recordedCityOfIssue" : "textField",
"recordedStateOrProvinceOfIssue" : "textField",
"recordedPaperNumber" : "textField",
"recordedFamilyNumber" : "textField",
"recordedOrderNumber" : "textField",
"issueRecordNumber" : "textField"
}
},
"personalAttributes" : {
"socialNumber" : "textField",
"surname" : "textField",
"name" : "textField",
"paternalName" : "textField",
"maternalName" : "textField",
"placeOfBirth" : "textField",
"dateOfBirth" : "dateField",
"maritalStatus" : "textField",
"gender" : "textField"
}
}
When I try to render text inputs on my template as follow;
<v-expansion-panel>
<v-expansion-panel-header>Document Attributes</v-expansion-panel-header>
<v-expansion-panel-content
v-for="(value,name,index) in refJSON"
:key="name"
>
<v-text-field
:label="name"
:placeholder="name"
:id="index"
:value="name"
v-model="docAttributesExtractionResult[index].name"
/>
</v-expansion-panel-content>
</v-expansion-panel>
I create an array to save typed values from dynamically generated text fields in template rendering but I couldn't achieve it so far as all text fields are having the same value as soon as I type anything on the field.
data: () => ({
docAttributesExtractionResult: [{}, {}, {}, {}],
}),
I'm basically trying to achieve the following result on my docAttributesExtractionResult array
docAttributesExtractionResult: [{"documentNumber":"typedValue"}, {"issueDate":"selectedDateValue",.... etc}
Does anyone have any clue on achieving this with correct v-model binding on the array?
An example fiddle which I'm trying to do the same but couldn't succeed.