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

前端 未结 3 578
长情又很酷
长情又很酷 2020-12-01 11:35

I\'m displaying an html table for a filtered collection of entities and I want to display a checkbox in each row as part of a form which will add the selected entities to a

3条回答
  •  醉话见心
    2020-12-01 12:01

    If someone is looking for solution for Symfony >=2.3

    You have to change this:

        $data = $form->getData();
        $ids  = array();
        foreach ($data['foo_id'] as $entity) {
            $ids[] = $entity->getId();
        }
    

    to this:

        $data = $form['foo_id']->getData();
        $ids = array();
        foreach ($data as $entity) {
            $ids[] = $entity->getId();
        }
    

提交回复
热议问题