Symfony 2 Embedded forms using one to many db relationship

前端 未结 2 2113
鱼传尺愫
鱼传尺愫 2021-02-09 06:17

I\'m have a problem embedding forms from different entities in one form, my form is being displayed with firstname [input] lastname [input] address - but the address has no inpu

2条回答
  •  灰色年华
    2021-02-09 07:15

    Llewellyn, do you mean something like thid:

    public function editAction($id) { $em = $this->getDoctrine()->getManager();

        $entity = $em->getRepository('imBundle:Inspecciones')->find($id);
    
        $entity_valores = $em->getRepository('imBundle:ValoresInspecciones')->findByInspecciones($id);
    
        if (!$entity) {
            throw $this->createNotFoundException('Unable to find Inspecciones entity.');
        }
    
        $entity->setValoresInspecciones($entity_valores);
    
    
    
        $editForm = $this->createEditForm($entity);
        $deleteForm = $this->createDeleteForm($id);
    
        return $this->render('imBundle:Inspecciones:edit.html.twig', array(
            'entity'      => $entity,
            'edit_form'   => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        ));
    }
    

提交回复
热议问题