相关疑难解决方法(0)

Symfony 3.0嵌套实体不保存

所以我有一个实验实体,它有许多RNASeq实体.但是,当我尝试使用RNASeq条目(通过newAction)保存实验时,只保存实验部分.

我的控制器如下:

    <?php
    // src/AppBundle/Controller/ExperimentController.php
    namespace AppBundle\Controller;

    use AppBundle\Entity\Experiment;
    use AppBundle\Entity\RNASeq;
    use AppBundle\Form\Type\ExperimentType;
    use Symfony\Bundle\FrameworkBundle\Controller\Controller;
    use Symfony\Component\HttpFoundation\Request;
    use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
    use Symfony\Component\HttpFoundation\Response;

    // TODO: deleteAction should be implemented. 

    class ExperimentController extends Controller {
        /**
         * @Route("/experiment/index", name="experiment_index")
         */
        public function indexAction() {
            // Grab all experiments from database and hand them to template. 
            $repository = $this->getDoctrine()->getRepository('AppBundle:Experiment');
            $experiments = $repository->findAll();
            return $this->render('experiment/index.html.twig',['experiments' => $experiments]);
        }

        /**
         * @Route("/experiment/new", name="experiment_new")
         */
        public function newAction(Request $request) {
            $experiment = new Experiment();

            $form …
Run Code Online (Sandbox Code Playgroud)

php symfony doctrine-orm

2
推荐指数
1
解决办法
2684
查看次数

标签 统计

doctrine-orm ×1

php ×1

symfony ×1