Skip to content

[Form] Extend CollectionType to handle custom keys #7828

Closed
@webmozart

Description

@webmozart

Right now, CollectionType is designed to work only with numerically and incrementally indexed collections. An interesting extension (see #7807) is to allow customly indexed collections as well by using the value of one of the fields in a row as key for the respective entry. The feature could be activated by setting an option such as index_by that configures the property path to the key in the data of the row.

Example:

$builder->add('employees', 'collection', array(
    'type' => 'employee',
    'index_by' => 'sin',
));

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions