Skip to content

How to Embed a Collection of Forms #3679

Closed
@trsteel88

Description

@trsteel88

http://symfony.com/doc/current/cookbook/form/form_collections.html#allowing-new-tags-with-the-prototype

I noticed an issue with the above cookbook entry. It determines the index by counting the elements. However, this will cause issues when you are adding/deleting tags.

Eg, say you start with 3 entities in the collection. The fields would be outputted as

  • tag[0][field]
  • tag[1][field]
  • tag[2][field]

Now, I delete the tag "1" with javascript. Result is:

  • tag[0][field]
  • tag[2][field]

Now, I add a new tag using js. Result will be:

  • tag[0][field]
  • tag[2][field]
  • tag[2][field]

You will notice there are now 2 rows with the same index. How do people get around this. Should we be generating a random index instead of a length based index?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions