Symfony2 - 制作可选择的实体列表

In my Symfony2, I have a table of a user's emails (entities in my database):

{% for email in emails %}
    ...
    {{ email.subject }}
    ...
{% endfor %}

I would like to make these selectable by wrapping the table in a form and adding a checkbox to each of these rows.

What's the best way to approach this in Symfony2? I can only think that I'll have to create a Type inside a Type inside a Type, which seems less than ideal:

class SelectableEmailsType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('selectableEmails', 'collection', [ 'type' => new SelectableEmailType() ]);
    }

    public function getName()
    {
        return 'selectableEmails';
    }
}

class SelectableEmailType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('email', new EmailType());
        $builder->add('selected', 'checkbox');
    }

    public function getName()
    {
        return 'selectableEmail';
    }
}

class EmailType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('subject', 'text');
        ...
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults([
            'data_class' => 'EmailOctopus\Bundle\ListsBundle\Entity\ListEntity',
        ]);
    }

    public function getName()
    {
        return 'email';
    }
}

This is answering the binding question.

// Query a list of emails
$emails = $emailRepository->findAll();

// Turn them into selectable emails
$selectableEmails = array();
foreach($emails as $email)
{
    $selectableEmails[] = array('email' => $email, 'selected' => false);
}

// Pass this to the root form
$formData = array('selectableEmails' => $selectableEmails);

After processing a posted form you would pull out the list of selectableEmails and run through it to get the list actually selected.

This is just one approach. It works well for adding additional form related attributes to an entity without changing the entity itself.

I ended up assigning the id. of each email to a checkbox, using this solution:

Build a form having a checkbox for each entity in a doctrine collection