0

我想为我的学生做一个测验(真的很简单)。我有 2 个实体,一个问题和一个答案,与一个答案实体的关系 onetomany。我希望能够为 tex X 编写问题并将所有问题都放在带有字段答案的页面中。

示例:1) 问题 1

<input name question1>

2) 问题 2

<input name question2>

我暂时这样做了:

public function newAction() {
    $em = $this->getDoctrine()->getManager();
    $entities = $em->getRepository('AdminQuizBundle:Question')->findAll();

    $questions = array();
    $forms = array();

    foreach ($entities as $question) {
        $entity = new Reponse();
        $form = $this->createForm(new ReponseType(), $entity);

        $questions[] = $question; 
        $forms[] = $form->createView();
    }

    return array(
        'entity' => $entity,
        'form' => $forms,
        'questions' => $questions,
    );


}

它有效,但我尝试保存最后一个

4

0 回答 0