Catchable Fatal Error: Argument 1 passed to MyProject\EntityBundle\Entity\Requirements::setReplacedEmployee() must be an instance of MyProject\EntityBundle\Entity\Employee, null given, called in /var/www/MyProject/vendor/symfony/src/Symfony/Component/Form/Util/PropertyPath.php on line 347 and defined in /var/www/MyProject/src/MyProject/EntityBundle/Entity/Requirements.php line 384
Should do this:
I can't fully understand your question but, if you want to allow
null
values for the relation with Employee
you should first edit the mapping (this maybe not necessary as JoinColumn
should allow null
values by default): /**
* @var replacedEmployee
*
* @ORM\ManyToOne(cascade={"persist"},targetEntity="Employee")
* @ORM\JoinColumns({
* @ORM\JoinColumn(
* name="replaced_employee_id",referencedColumnName="id",onDelete="CASCADE",
* nullable=true
* )
* })
*/
private $replacedEmployee;
After generating setters/getters Doctrine2 (if i remember correctly, starting from 2.2.1) should generate:
/**
* Set replacedEmployee
*
* @param MyProject\EntityBundle\Entity\Employee $replacedEmployee
*/
public function setReplacedEmployee(Employee $replacedEmployee = null)
{
$this->replacedEmployee = $replacedEmployee;
}
Note that argument is optional (has
null
default value). Hope this helps.
评论
发表评论