Trzeba stworzyć ManyToOne relacji między swój komentarz i wizerunku podmiotów.
Więcej informacji na temat skojarzeń z doktryną 2 here.
Komentarz
/**
* @ORM\ManyToOne(targetEntity="Image", inversedBy="comment")
*/
protected $images;
public function __construct()
{
$this->images = new ArrayCollection();
}
public function getImages()
{
return $this->images;
}
public function addImage(ImageInterface $image)
{
if (!$this->images->contains($image)) {
$this->images->add($image);
}
return $this;
}
public function removeImage(ImageInterface $image)
{
$this->images->remove($image);
return $this;
}
public function setImages(Collection $images)
{
$this->images = $images;
}
// ...
Obraz
protected $comment;
public function getComment()
{
return $this->comment;
}
public function setComment(CommentInterface $comment)
{
$this->comment = $comment;
return $this;
}
// ...
Następnie dodać pole collection form do CommentFormType z "typ" z ImageFormType (być utworzone).
Proszę przejrzeć mój komentarz i zaakceptować go, jeśli w przeciwnym razie skomentuj to, czego nie rozumiesz, wtedy zaktualizuję moją odpowiedź. – nifr