我尝试在 symfony2.1 中提交表格,但出现以下错误,我创建表格学生注册并尝试提交,我为此查看了可能的论坛,但没有得到任何适当的解决方案。
Error:Catchable Fatal Error: Argument 1 passed to
Frontend\EntityBundle\Entity\StudentRegistration::setIdCountry()
must be an instance of Frontend\EntityBundle\Entity\MasterCountry, string given,
called in C:\wamp\www\careerguide\src\Frontend\HomeBundle\Controller\RegistrationController.php
on line 41 and defined in C:\wamp\www\careerguide\src\Frontend\EntityBundle\Entity\StudentRegistration.php line 1253
在控制器中我有:
$student_account = new \Frontend\EntityBundle\Entity\StudentRegistration();
$params = $request->get('student_registration');
$student_account->setIdCountry($params['idCountry']);
$em = $this->getDoctrine()->getEntityManager();
$em->persist($student_account);
$em->flush();
实体类:
/**
* @var MasterCountry
*
* @ORM\ManyToOne(targetEntity="MasterCountry")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_country", referencedColumnName="id_country")
* })
*/
private $idCountry;
请建议我如何解决此错误?