更新时间:2021-12-13 22:41:16
更好的解决方案是允许设置 null 并让验证报告错误.
Better solution is to allow set the null and let the validation reports the error.
/**
* @var \DateTime
* @ORM\Column(name="task_date_start", type="datetime", nullable=false)
* @Assert\NotBlank()
*/
private $taskDateStart;
和
function setTaskDateStart(?\DateTime $taskDateStart) {
$this->taskDateStart = $taskDateStart;
}