I have a class that have relationships with other classes in my Bundle, and whenever I try to generate a form with the Doctrine command in Symfony, it fails by returning a Twig error
Key "school" for array with keys "id, startDate, endDate" does not exists in "form/formType.php.twig" at line 29 Here is my code:
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Classroom
*
* @ORM\Table(name="classroom")
* @ORM\Entity(repositoryClass="AppBundle\Repository\ClassroomRepository")
*/
class Classroom
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\School", inversedBy="classrooms")
* @ORM\JoinColumn(nullable=false)
*/
private $school;
/**
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Student", mappedBy="classroom")
* @ORM\JoinColumn(nullable=false)
*/
private $students;
/**
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\Teacher")
* @ORM\JoinColumn(nullable=false)
*/
private $teachers;
/**
* @var \DateTime
*
* @ORM\Column(name="start_date", type="date")
*/
private $startDate;
/**
* @var \DateTime
*
* @ORM\Column(name="end_date", type="date")
*/
private $endDate;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set startDate
*
* @param \DateTime $startDate
*
* @return Classroom
*/
public function setStartDate($startDate)
{
$this->startDate = $startDate;
return $this;
}
/**
* Get startDate
*
* @return \DateTime
*/
public function getStartDate()
{
return $this->startDate;
}
/**
* Set endDate
*
* @param \DateTime $endDate
*
* @return Classroom
*/
public function setEndDate($endDate)
{
$this->endDate = $endDate;
return $this;
}
/**
* Get endDate
*
* @return \DateTime
*/
public function getEndDate()
{
return $this->endDate;
}
/**
* Set school
*
* @param \AppBundle\Entity\School $school
*
* @return Classroom
*/
public function setSchool(\AppBundle\Entity\School $school)
{
$this->school = $school;
return $this;
}
/**
* Get school
*
* @return \AppBundle\Entity\School
*/
public function getSchool()
{
return $this->school;
}
/**
* Constructor
*/
public function __construct()
{
$this->students = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add student
*
* @param \AppBundle\Entity\Student $student
*
* @return Classroom
*/
public function addStudent(\AppBundle\Entity\Student $student)
{
$this->students[] = $student;
return $this;
}
/**
* Remove student
*
* @param \AppBundle\Entity\Student $student
*/
public function removeStudent(\AppBundle\Entity\Student $student)
{
$this->students->removeElement($student);
}
/**
* Get students
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getStudents()
{
return $this->students;
}
/**
* Add teacher
*
* @param \AppBundle\Entity\Teacher $teacher
*
* @return Classroom
*/
public function addTeacher(\AppBundle\Entity\Teacher $teacher)
{
$this->teachers[] = $teacher;
return $this;
}
/**
* Remove teacher
*
* @param \AppBundle\Entity\Teacher $teacher
*/
public function removeTeacher(\AppBundle\Entity\Teacher $teacher)
{
$this->teachers->removeElement($teacher);
}
/**
* Get teachers
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getTeachers()
{
return $this->teachers;
}
}
Do I need to add anything for it to works ? Is it because of the relationships with another class ? Hope you can help me