当我尝试验证使用 validation.yml 文件提交的实体类型表单时收到以下错误消息
可捕获的致命错误:传递给 Frontend\EntityBundle\Entity\StudentRegistration::setIdState() 的参数 1 必须是 Frontend\EntityBundle\Entity\MasterState 的实例,给定 null,在 C:\wamp\www\careerguide\vendor\symfony 中调用\src\Symfony\Component\Form\Util\PropertyPath.php 在第 347 行并在 C:\wamp\www\careerguide\src\Frontend\EntityBundle\Entity\StudentRegistration.php 第 1099 行中定义
通知,
->add('idState', 'entity', array('class' => 'Frontend\EntityBundle\Entity\MasterState', 'property' => 'stateName', 'empty_value' => '选择状态', 'label ' => 'State :', 'attr' => array('class' => 'width275'), 'required' => false))
在实体中,
<?php
命名空间前端\EntityBundle\Entity;
使用 Doctrine\ORM\Mapping 作为 ORM;
/** * Frontend\EntityBundle\Entity\StudentRegistration * * @ORM\Table(name="student_registration") * @ORM\Entity / class StudentRegistration { / * * @var integer $id * * @ORM\Column(name= "id", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id;
/**
* @var string $idStudentRegistration
*
* @ORM\Column(name="id_student_registration", type="string", length=128, nullable=false)
*/
private $idStudentRegistration;
/**
* @var integer $idAttempt
*
* @ORM\Column(name="id_attempt", type="integer", nullable=true)
*/
private $idAttempt;
/**
* @var string $firstName
*
* @ORM\Column(name="first_name", type="string", length=128, nullable=false)
*/
private $firstName;
/**
* @var string $lastName
*
* @ORM\Column(name="last_name", type="string", length=128, nullable=true)
*/
private $lastName;
/**
* @var datetime $dateOfBirth
*
* @ORM\Column(name="date_of_birth", type="datetime", nullable=true)
*/
private $dateOfBirth;
/**
* @var string $gender
*
* @ORM\Column(name="gender", type="string", length=16, nullable=true)
*/
private $gender;
/**
* @var string $email
*
* @ORM\Column(name="email", type="string", length=128, nullable=true)
*/
private $email;
/**
* @var string $password
*
* @ORM\Column(name="password", type="string", length=128, nullable=true)
*/
private $password;
/**
* @var string $mobileNumber
*
* @ORM\Column(name="mobile_number", type="string", length=16, nullable=true)
*/
private $mobileNumber;
/**
* @var string $stdCode
*
* @ORM\Column(name="std_code", type="string", length=16, nullable=true)
*/
private $stdCode;
/**
* @var integer $landlineNumber
*
* @ORM\Column(name="landline_number", type="integer", nullable=true)
*/
private $landlineNumber;
/**
* @var text $address
*
* @ORM\Column(name="address", type="text", nullable=true)
*/
private $address;
/**
* @var integer $pincode
*
* @ORM\Column(name="pincode", type="integer", nullable=true)
*/
private $pincode;
/**
* @var string $disabilityPercentage
*
* @ORM\Column(name="disability_percentage", type="string", length=16, nullable=true)
*/
private $disabilityPercentage;
/**
* @var string $schoolName
*
* @ORM\Column(name="school_name", type="string", length=256, nullable=true)
*/
private $schoolName;
/**
* @var string $collegeName
*
* @ORM\Column(name="college_name", type="string", length=256, nullable=true)
*/
private $collegeName;
/**
* @var string $qualificationStatus
*
* @ORM\Column(name="qualification_status", type="string", length=128, nullable=true)
*/
private $qualificationStatus;
/**
* @var string $courseDuration
*
* @ORM\Column(name="course_duration", type="string", length=16, nullable=true)
*/
private $courseDuration;
/**
* @var string $workExposure
*
* @ORM\Column(name="work_exposure", type="string", length=16, nullable=true)
*/
private $workExposure;
/**
* @var string $userStudyDuration
*
* @ORM\Column(name="user_study_duration", type="string", length=16, nullable=true)
*/
private $userStudyDuration;
/**
* @var text $achievements
*
* @ORM\Column(name="achievements", type="text", nullable=true)
*/
private $achievements;
/**
* @var datetime $createdAt
*
* @ORM\Column(name="created_at", type="datetime", nullable=true)
*/
private $createdAt;
/**
* @var datetime $updatedAt
*
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @var integer $version
*
* @ORM\Column(name="version", type="integer", nullable=true)
*/
private $version;
/**
* @var MasterCity
*
* @ORM\ManyToOne(targetEntity="MasterCity")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_city", referencedColumnName="id")
* })
*/
private $idCity;
/**
* @var MasterStreamgroup
*
* @ORM\ManyToOne(targetEntity="MasterStreamgroup")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_streamgroup", referencedColumnName="id")
* })
*/
private $idStreamgroup;
/**
* @var MasterQualification
*
* @ORM\ManyToOne(targetEntity="MasterQualification")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_qualification_father", referencedColumnName="id")
* })
*/
private $idQualificationFather;
/**
* @var MasterOccupation
*
* @ORM\ManyToOne(targetEntity="MasterOccupation")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_occupation_father", referencedColumnName="id")
* })
*/
private $idOccupationFather;
/**
* @var MasterQualification
*
* @ORM\ManyToOne(targetEntity="MasterQualification")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_qualification_mother", referencedColumnName="id")
* })
*/
private $idQualificationMother;
/**
* @var MasterOccupation
*
* @ORM\ManyToOne(targetEntity="MasterOccupation")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_occupation_mother", referencedColumnName="id")
* })
*/
private $idOccupationMother;
/**
* @var MasterCity
*
* @ORM\ManyToOne(targetEntity="MasterCity")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_preferred_city1", referencedColumnName="id")
* })
*/
private $idPreferredCity1;
/**
* @var MasterCity
*
* @ORM\ManyToOne(targetEntity="MasterCity")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_preferred_city2", referencedColumnName="id")
* })
*/
private $idPreferredCity2;
/**
* @var MasterCity
*
* @ORM\ManyToOne(targetEntity="MasterCity")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_preferred_city3", referencedColumnName="id")
* })
*/
private $idPreferredCity3;
/**
* @var MasterBudget
*
* @ORM\ManyToOne(targetEntity="MasterBudget")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_budget", referencedColumnName="id")
* })
*/
private $idBudget;
/**
* @var MasterMode
*
* @ORM\ManyToOne(targetEntity="MasterMode")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_mode", referencedColumnName="id")
* })
*/
private $idMode;
/**
* @var MasterState
*
* @ORM\ManyToOne(targetEntity="MasterState")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_state", referencedColumnName="id")
* })
*/
private $idState;
/**
* @var MasterCountry
*
* @ORM\ManyToOne(targetEntity="MasterCountry")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_country", referencedColumnName="id")
* })
*/
private $idCountry;
/**
* @var MasterHealth
*
* @ORM\ManyToOne(targetEntity="MasterHealth")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_health", referencedColumnName="id")
* })
*/
private $idHealth;
/**
* @var MasterQualification
*
* @ORM\ManyToOne(targetEntity="MasterQualification")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_qualification", referencedColumnName="id")
* })
*/
private $idQualification;
/**
* @var MasterMedium
*
* @ORM\ManyToOne(targetEntity="MasterMedium")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_medium", referencedColumnName="id")
* })
*/
private $idMedium;
/**
* @var MasterBoard
*
* @ORM\ManyToOne(targetEntity="MasterBoard")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_board", referencedColumnName="id")
* })
*/
private $idBoard;
/**
* @var MasterUniversity
*
* @ORM\ManyToOne(targetEntity="MasterUniversity")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_university", referencedColumnName="id")
* })
*/
private $idUniversity;
/**
* @var MasterStream
*
* @ORM\ManyToOne(targetEntity="MasterStream")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_stream", referencedColumnName="id")
* })
*/
private $idStream;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set idStudentRegistration
*
* @param string $idStudentRegistration
*/
public function setIdStudentRegistration($idStudentRegistration)
{
$this->idStudentRegistration = $idStudentRegistration;
}
/**
* Get idStudentRegistration
*
* @return string
*/
public function getIdStudentRegistration()
{
return $this->idStudentRegistration;
}
/**
* Set idAttempt
*
* @param integer $idAttempt
*/
public function setIdAttempt($idAttempt)
{
$this->idAttempt = $idAttempt;
}
/**
* Get idAttempt
*
* @return integer
*/
public function getIdAttempt()
{
return $this->idAttempt;
}
/**
* Set firstName
*
* @param string $firstName
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
}
/**
* Get firstName
*
* @return string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* Set lastName
*
* @param string $lastName
*/
public function setLastName($lastName)
{
$this->lastName = $lastName;
}
/**
* Get lastName
*
* @return string
*/
public function getLastName()
{
return $this->lastName;
}
/**
* Set dateOfBirth
*
* @param datetime $dateOfBirth
*/
public function setDateOfBirth($dateOfBirth)
{
$this->dateOfBirth = $dateOfBirth;
}
/**
* Get dateOfBirth
*
* @return datetime
*/
public function getDateOfBirth()
{
return $this->dateOfBirth;
}
/**
* Set gender
*
* @param string $gender
*/
public function setGender($gender)
{
$this->gender = $gender;
}
/**
* Get gender
*
* @return string
*/
public function getGender()
{
return $this->gender;
}
/**
* Set email
*
* @param string $email
*/
public function setEmail($email)
{
$this->email = $email;
}
/**
* Get email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set password
*
* @param string $password
*/
public function setPassword($password)
{
$this->password = $password;
}
/**
* Get password
*
* @return string
*/
public function getPassword()
{
return $this->password;
}
/**
* Set mobileNumber
*
* @param string $mobileNumber
*/
public function setMobileNumber($mobileNumber)
{
$this->mobileNumber = $mobileNumber;
}
/**
* Get mobileNumber
*
* @return string
*/
public function getMobileNumber()
{
return $this->mobileNumber;
}
/**
* Set stdCode
*
* @param string $stdCode
*/
public function setStdCode($stdCode)
{
$this->stdCode = $stdCode;
}
/**
* Get stdCode
*
* @return string
*/
public function getStdCode()
{
return $this->stdCode;
}
/**
* Set landlineNumber
*
* @param integer $landlineNumber
*/
public function setLandlineNumber($landlineNumber)
{
$this->landlineNumber = $landlineNumber;
}
/**
* Get landlineNumber
*
* @return integer
*/
public function getLandlineNumber()
{
return $this->landlineNumber;
}
/**
* Set address
*
* @param text $address
*/
public function setAddress($address)
{
$this->address = $address;
}
/**
* Get address
*
* @return text
*/
public function getAddress()
{
return $this->address;
}
/**
* Set pincode
*
* @param integer $pincode
*/
public function setPincode($pincode)
{
$this->pincode = $pincode;
}
/**
* Get pincode
*
* @return integer
*/
public function getPincode()
{
return $this->pincode;
}
/**
* Set disabilityPercentage
*
* @param string $disabilityPercentage
*/
public function setDisabilityPercentage($disabilityPercentage)
{
$this->disabilityPercentage = $disabilityPercentage;
}
/**
* Get disabilityPercentage
*
* @return string
*/
public function getDisabilityPercentage()
{
return $this->disabilityPercentage;
}
/**
* Set schoolName
*
* @param string $schoolName
*/
public function setSchoolName($schoolName)
{
$this->schoolName = $schoolName;
}
/**
* Get schoolName
*
* @return string
*/
public function getSchoolName()
{
return $this->schoolName;
}
/**
* Set collegeName
*
* @param string $collegeName
*/
public function setCollegeName($collegeName)
{
$this->collegeName = $collegeName;
}
/**
* Get collegeName
*
* @return string
*/
public function getCollegeName()
{
return $this->collegeName;
}
/**
* Set qualificationStatus
*
* @param string $qualificationStatus
*/
public function setQualificationStatus($qualificationStatus)
{
$this->qualificationStatus = $qualificationStatus;
}
/**
* Get qualificationStatus
*
* @return string
*/
public function getQualificationStatus()
{
return $this->qualificationStatus;
}
/**
* Set courseDuration
*
* @param string $courseDuration
*/
public function setCourseDuration($courseDuration)
{
$this->courseDuration = $courseDuration;
}
/**
* Get courseDuration
*
* @return string
*/
public function getCourseDuration()
{
return $this->courseDuration;
}
/**
* Set workExposure
*
* @param string $workExposure
*/
public function setWorkExposure($workExposure)
{
$this->workExposure = $workExposure;
}
/**
* Get workExposure
*
* @return string
*/
public function getWorkExposure()
{
return $this->workExposure;
}
/**
* Set userStudyDuration
*
* @param string $userStudyDuration
*/
public function setUserStudyDuration($userStudyDuration)
{
$this->userStudyDuration = $userStudyDuration;
}
/**
* Get userStudyDuration
*
* @return string
*/
public function getUserStudyDuration()
{
return $this->userStudyDuration;
}
/**
* Set achievements
*
* @param text $achievements
*/
public function setAchievements($achievements)
{
$this->achievements = $achievements;
}
/**
* Get achievements
*
* @return text
*/
public function getAchievements()
{
return $this->achievements;
}
/**
* Set createdAt
*
* @param datetime $createdAt
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
}
/**
* Get createdAt
*
* @return datetime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set updatedAt
*
* @param datetime $updatedAt
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
}
/**
* Get updatedAt
*
* @return datetime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set version
*
* @param integer $version
*/
public function setVersion($version)
{
$this->version = $version;
}
/**
* Get version
*
* @return integer
*/
public function getVersion()
{
return $this->version;
}
/**
* Set idCity
*
* @param Frontend\EntityBundle\Entity\MasterCity $idCity
*/
public function setIdCity(\Frontend\EntityBundle\Entity\MasterCity $idCity)
{
$this->idCity = $idCity;
}
/**
* Get idCity
*
* @return Frontend\EntityBundle\Entity\MasterCity
*/
public function getIdCity()
{
return $this->idCity;
}
/**
* Set idStreamgroup
*
* @param Frontend\EntityBundle\Entity\MasterStreamgroup $idStreamgroup
*/
public function setIdStreamgroup(\Frontend\EntityBundle\Entity\MasterStreamgroup $idStreamgroup)
{
$this->idStreamgroup = $idStreamgroup;
}
/**
* Get idStreamgroup
*
* @return Frontend\EntityBundle\Entity\MasterStreamgroup
*/
public function getIdStreamgroup()
{
return $this->idStreamgroup;
}
/**
* Set idQualificationFather
*
* @param Frontend\EntityBundle\Entity\MasterQualification $idQualificationFather
*/
public function setIdQualificationFather(\Frontend\EntityBundle\Entity\MasterQualification $idQualificationFather)
{
$this->idQualificationFather = $idQualificationFather;
}
/**
* Get idQualificationFather
*
* @return Frontend\EntityBundle\Entity\MasterQualification
*/
public function getIdQualificationFather()
{
return $this->idQualificationFather;
}
/**
* Set idOccupationFather
*
* @param Frontend\EntityBundle\Entity\MasterOccupation $idOccupationFather
*/
public function setIdOccupationFather(\Frontend\EntityBundle\Entity\MasterOccupation $idOccupationFather)
{
$this->idOccupationFather = $idOccupationFather;
}
/**
* Get idOccupationFather
*
* @return Frontend\EntityBundle\Entity\MasterOccupation
*/
public function getIdOccupationFather()
{
return $this->idOccupationFather;
}
/**
* Set idQualificationMother
*
* @param Frontend\EntityBundle\Entity\MasterQualification $idQualificationMother
*/
public function setIdQualificationMother(\Frontend\EntityBundle\Entity\MasterQualification $idQualificationMother)
{
$this->idQualificationMother = $idQualificationMother;
}
/**
* Get idQualificationMother
*
* @return Frontend\EntityBundle\Entity\MasterQualification
*/
public function getIdQualificationMother()
{
return $this->idQualificationMother;
}
/**
* Set idOccupationMother
*
* @param Frontend\EntityBundle\Entity\MasterOccupation $idOccupationMother
*/
public function setIdOccupationMother(\Frontend\EntityBundle\Entity\MasterOccupation $idOccupationMother)
{
$this->idOccupationMother = $idOccupationMother;
}
/**
* Get idOccupationMother
*
* @return Frontend\EntityBundle\Entity\MasterOccupation
*/
public function getIdOccupationMother()
{
return $this->idOccupationMother;
}
/**
* Set idPreferredCity1
*
* @param Frontend\EntityBundle\Entity\MasterCity $idPreferredCity1
*/
public function setIdPreferredCity1(\Frontend\EntityBundle\Entity\MasterCity $idPreferredCity1)
{
$this->idPreferredCity1 = $idPreferredCity1;
}
/**
* Get idPreferredCity1
*
* @return Frontend\EntityBundle\Entity\MasterCity
*/
public function getIdPreferredCity1()
{
return $this->idPreferredCity1;
}
/**
* Set idPreferredCity2
*
* @param Frontend\EntityBundle\Entity\MasterCity $idPreferredCity2
*/
public function setIdPreferredCity2(\Frontend\EntityBundle\Entity\MasterCity $idPreferredCity2)
{
$this->idPreferredCity2 = $idPreferredCity2;
}
/**
* Get idPreferredCity2
*
* @return Frontend\EntityBundle\Entity\MasterCity
*/
public function getIdPreferredCity2()
{
return $this->idPreferredCity2;
}
/**
* Set idPreferredCity3
*
* @param Frontend\EntityBundle\Entity\MasterCity $idPreferredCity3
*/
public function setIdPreferredCity3(\Frontend\EntityBundle\Entity\MasterCity $idPreferredCity3)
{
$this->idPreferredCity3 = $idPreferredCity3;
}
/**
* Get idPreferredCity3
*
* @return Frontend\EntityBundle\Entity\MasterCity
*/
public function getIdPreferredCity3()
{
return $this->idPreferredCity3;
}
/**
* Set idBudget
*
* @param Frontend\EntityBundle\Entity\MasterBudget $idBudget
*/
public function setIdBudget(\Frontend\EntityBundle\Entity\MasterBudget $idBudget)
{
$this->idBudget = $idBudget;
}
/**
* Get idBudget
*
* @return Frontend\EntityBundle\Entity\MasterBudget
*/
public function getIdBudget()
{
return $this->idBudget;
}
/**
* Set idMode
*
* @param Frontend\EntityBundle\Entity\MasterMode $idMode
*/
public function setIdMode(\Frontend\EntityBundle\Entity\MasterMode $idMode)
{
$this->idMode = $idMode;
}
/**
* Get idMode
*
* @return Frontend\EntityBundle\Entity\MasterMode
*/
public function getIdMode()
{
return $this->idMode;
}
/**
* Set idState
*
* @param Frontend\EntityBundle\Entity\MasterState $idState
*/
public function setIdState(\Frontend\EntityBundle\Entity\MasterState $idState)
{
$this->idState = $idState;
}
/**
* Get idState
*
* @return Frontend\EntityBundle\Entity\MasterState
*/
public function getIdState()
{
return $this->idState;
}
/**
* Set idCountry
*
* @param Frontend\EntityBundle\Entity\MasterCountry $idCountry
*/
public function setIdCountry(\Frontend\EntityBundle\Entity\MasterCountry $idCountry)
{
$this->idCountry = $idCountry;
}
/**
* Get idCountry
*
* @return Frontend\EntityBundle\Entity\MasterCountry
*/
public function getIdCountry()
{
return $this->idCountry;
}
/**
* Set idHealth
*
* @param Frontend\EntityBundle\Entity\MasterHealth $idHealth
*/
public function setIdHealth(\Frontend\EntityBundle\Entity\MasterHealth $idHealth)
{
$this->idHealth = $idHealth;
}
/**
* Get idHealth
*
* @return Frontend\EntityBundle\Entity\MasterHealth
*/
public function getIdHealth()
{
return $this->idHealth;
}
/**
* Set idQualification
*
* @param Frontend\EntityBundle\Entity\MasterQualification $idQualification
*/
public function setIdQualification(\Frontend\EntityBundle\Entity\MasterQualification $idQualification)
{
$this->idQualification = $idQualification;
}
/**
* Get idQualification
*
* @return Frontend\EntityBundle\Entity\MasterQualification
*/
public function getIdQualification()
{
return $this->idQualification;
}
/**
* Set idMedium
*
* @param Frontend\EntityBundle\Entity\MasterMedium $idMedium
*/
public function setIdMedium(\Frontend\EntityBundle\Entity\MasterMedium $idMedium)
{
$this->idMedium = $idMedium;
}
/**
* Get idMedium
*
* @return Frontend\EntityBundle\Entity\MasterMedium
*/
public function getIdMedium()
{
return $this->idMedium;
}
/**
* Set idBoard
*
* @param Frontend\EntityBundle\Entity\MasterBoard $idBoard
*/
public function setIdBoard(\Frontend\EntityBundle\Entity\MasterBoard $idBoard)
{
$this->idBoard = $idBoard;
}
/**
* Get idBoard
*
* @return Frontend\EntityBundle\Entity\MasterBoard
*/
public function getIdBoard()
{
return $this->idBoard;
}
/**
* Set idUniversity
*
* @param Frontend\EntityBundle\Entity\MasterUniversity $idUniversity
*/
public function setIdUniversity(\Frontend\EntityBundle\Entity\MasterUniversity $idUniversity)
{
$this->idUniversity = $idUniversity;
}
/**
* Get idUniversity
*
* @return Frontend\EntityBundle\Entity\MasterUniversity
*/
public function getIdUniversity()
{
return $this->idUniversity;
}
/**
* Set idStream
*
* @param Frontend\EntityBundle\Entity\MasterStream $idStream
*/
public function setIdStream(\Frontend\EntityBundle\Entity\MasterStream $idStream)
{
$this->idStream = $idStream;
}
/**
* Get idStream
*
* @return Frontend\EntityBundle\Entity\MasterStream
*/
public function getIdStream()
{
return $this->idStream;
}
}
在validation.yml
idState: - NotBlank: { message: "请选择状态。", groups: [personalDetails] }