当我发送带有空白字段的表单时,我收到错误消息SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'image' cannot be null
。我发现修复它的唯一方法是在实体文件中设置一个默认值:
* @ORM\Column(type="string", length=100)
*/
protected $image="";
并像这样更改设置器:
public function setImage($image){
if(!isset($image)) {
//its really empty but it works only in this way
}
else {
$this->image = $image;
}
我认为这非常严重......对此有什么解释吗?还有另一种方法吗?}