How to fill this array?

Posted 1 week ago by marcellopato

I have this v-for:

<li v-for="(socio, index) in socios" class="list-group-item">
                            <div class="row">
                                <div class="col-sm-6">
                                    <label>Nome</label>
                                    <input type="text" name="socios[][nome]" class="form-control" disabled
                                        :placeholder="socio.nome + ' - ' + socio.qual" :value="socio.nome + ' - ' + socio.qual" v-model="socio.nome">
                                </div>
                                <div class="col-sm-2">
                                    <label>C.P.F.</label>
                                    <input type="text" name="socios[][cpf]" class="form-control" placeholder="###.###.###-##" v-mask="'###.###.###-##'">
                                </div>
                                <div class="col-sm-2">
                                    <label>R.G.</label>
                                    <input type="text" name="socios[][rg]" class="form-control" placeholder="##.###.###-#" v-mask="'##.###.###-#'">
                                </div>
                                <div class="col-sm-2">
                                    <label>Órgão Exp.</label>
                                    <input type="text" name="socios[][orgaoExp]" class="form-control">
                                </div>
                            </div>
                        </li>

This first input fills on the fly, cause the data came from a response. The others, like: 'cpf', 'rg' and 'orgaoExp' must be filled by the user.

When sending the form I got this print:

"socios": [
{
"cpf": "132.555.555-55"
},
{
"rg": "55.555.555-5"
},
{
"orgaoExp": "SSP"
},
{
"cpf": "987.986.546-53"
},
{
"rg": "98.765.465-1"
},
{
"orgaoExp": "SSP"
}
],

As you can see, the field 'nome' doesn't appears in the 'socios' array. How do I can do it?

Please!

Please sign in or create an account to participate in this conversation.