I am currently facing an issue with my form where each time a user updates a value in an input field, a new array element is created and added to the form results. I'm looking for a way to update the properties of the existing array element without creating a new one. How can I achieve this?
For instance, when editing the fields in the form below, it creates a new array element every time instead of updating the name
and iso6393Char3Code
properties:
[
{
"P_uniqueID": 16858,
"name": "Badakhshān",
"iso6393Char3Code": "fas"
},
{
"P_uniqueID": 16859,
"name": "Badakhshān",
"iso6393Char3Code": "pus"
}
]
The current behavior is resulting in multiple duplicate array elements being created as shown below:
[
{
"P_uniqueID": 16858,
"name": "Badakhshānsss",
"iso6393Char3Code": "fas"
},
{
"P_uniqueID": 16859,
"name": "Badakhshān",
"iso6393Char3Code": "pus"
},
{
"P_uniqueID": 16858,
"name": "Badakhshānsss",
"iso6393Char3Code": "fas"
},
{
"P_uniqueID": 16858,
"name": "Badakhshānsss",
"iso6393Char3Code": "fas"
},
{
"P_uniqueID": 16858,
"name": "Badakhshānsss",
"iso6393Char3Code": "fas"
}
]
You can view the Codesandbox example here: https://codesandbox.io/s/interesting-haze-f7kl4?file=/src/components/ISOAdminDivForm.vue