我試圖在symfony2.1中提交表單,但我得到以下錯誤,我創建了表單學生註冊並嘗試提交它,但我無法得到任何適當的解決方案。參數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;
請給我建議我做些什麼來解決這個問題?