Symfony2 form collection: Index of the current object is shown

Removing indexes (labels) for collection items:

$builder            
    ->add('person', 'collection', array(
        ...
        'options' => array('label' => false)
    ))
;

Use key entry_options instead of options for Symfony 3 and 4

If you want to add custom labels per row you can produce the form yourself:

{{ form_start(edit_form) }}
    {% for person in form.persons %}
        {{ form_row(person, {'label': 'custom label per item' }) }}
    {% endfor %}
{{ form_end(edit_form) }}

Note: tested on Symfony 2.3 & 2.4

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)