I have an Symfony2 project cnnected to the database. For each table I have an entity.
Now, I am trying to connect one Entity with another using ManyToOne.
Here is the problem:
I have Two entitys: User and Workplace.
In the User Entity, I have:
 /**
 * @ORM\ManyToOne(targetEntity="Workplace")
 * @ORM\JoinColumn(name="workplace", referencedColumnName="place")
 **/
protected $workplace;
/**
 * Set workplace
 *
 * @param integer $workplace
 */
public function setWorkplace($workplace)
{
    $this->workplace = $workplace;
}
/**
 * Get workplace
 *
 * @return integer 
 */
public function getWorkplace()
{
    return $this->workplace;
}
In the Workplace Entity I have:
/**
 * @ORM\Column(type="text")
 */
protected $place;
/**
 * Set place
 *
 * @param text $place
 */
public function setPlace($place)
{
    $this->place = $place;
}
/**
 * Get place
 *
 * @return text 
 */
public function getPlace()
{
    return $this->place;
}
And with that, I am getting an exception:
Neither property "workplace" nor method "getWorkplace()" nor method "isWorkplace()" exists in class "SciForum\Version2Bundle\Entity\Workplace" 
How could this be resolved. Thank you very much.
Try this
->add('place','entity',  array('class'=>'yourBundle:WorkPlace',
                               'property'=>'place'))
in your form Type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With