protected function saveBlock(Block $formBlock, $timetable) { if (empty($this->block)) { $this->block = new Block(); $this->block->setTitle($formBlock->getTitle()); $this->block->setContent($formBlock->getContent()); $this->block->setTypeId($formBlock->getTypeId()); $this->block->setDomId($formBlock->getDomId()); } // we need to init the relations even if the block is already filled with the post values // because stop_point_id in post contains the navitiaId value and doctrine expects a bdd ID // Plus, init Relations updates modified dates of line entity or stopPoint $this->initRelation($formBlock, $timetable); $this->om->persist($this->block); $this->om->flush(); }