public function addAction() { if (!empty($_POST)) { // créer de nouveaux objets $product = new Product(); $image = new Image(); //récuperer les infos du formulaire $image->setName(htmlentities($_POST['image'])); $product->setName(htmlentities($_POST['name'])); $product->setImage($image); // passage des objets à Doctrine $this->em->persist($product); $this->em->persist($image); $this->em->flush(); // redirection header('Location: index.php?controller=product&action=index'); } $this->render('addProduction.php'); }