0

I need "repositories[][name]" to be left with the key value "repositories[key][name]" to group the values when the form is submitted.

I can't find a way to add the key value. How can I do this function?

<tr v-for="(repository, key) in options.repositories">
<td><input type="text" name="repositories[][name]"
           :value="repository.name"
           class="form-control">
</td>
<td><input type="text" name="repositories[][url]"
           :value="repository.url"
           class="form-control">
</td>
<td><input type="text" name="repositories[][type]"
           :value="repository.type"
           class="form-control">
</td>

EDIT: I need the three values of the image to be grouper with the value "key"

enter image description here

For exemple in this case:

repositories[key] = [name => 'Product Grid', url => '...', type => 'vcs']

For this I need the value "key" to be printed in html.

enter image description here

3
  • Can't you use :name="repositories[key][name]"? Commented Mar 20, 2020 at 13:57
  • Whats the data structure of options.repositories? Can you please update that in your ques with an eg mock ds? Commented Mar 20, 2020 at 14:56
  • @ShivamSingh I have updated the main post with an example. Commented Mar 23, 2020 at 9:01

1 Answer 1

1

To bind you only need to use : like this:

    <tr v-for="(repository, key) in options.repositories">
    <td><input type="text" :name="repositories[key][name]"
               :value="repository.name"
               class="form-control">
    </td>
    <td><input type="text" :name="repositories[key][url]"
               :value="repository.url"
               class="form-control">
    </td>
    <td><input type="text" :name="repositories[key][type]"
               :value="repository.type"
               class="form-control">
    </td>

Sign up to request clarification or add additional context in comments.

1 Comment

But this functionality does not print the value "key" to me in the html. I have updated the main post with an example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.