Doctrine orm symfony 4.4:日期时间必须是字符串?
我将一个项目从Symfony 3.4迁移到Symfony 4.4(带API平台的背面) 在一个实体中,我有一个日期字段,它是在今天的日期自动生成的,所以当我发布帖子或发布消息时,她不在我的JSON中Doctrine orm symfony 4.4:日期时间必须是字符串?,doctrine-orm,symfony4,api-platform.com,Doctrine Orm,Symfony4,Api Platform.com,我将一个项目从Symfony 3.4迁移到Symfony 4.4(带API平台的背面) 在一个实体中,我有一个日期字段,它是在今天的日期自动生成的,所以当我发布帖子或发布消息时,她不在我的JSON中 /** * @Groups({"get_logement", "post_logement", "put_logement"}) * @ORM\Column(type="datetime", nullable=false) * @Assert\Date(message=
/**
* @Groups({"get_logement", "post_logement", "put_logement"})
* @ORM\Column(type="datetime", nullable=false)
* @Assert\Date(message="the date is not correct.")
*/
private $dateEtat;
和一个结构:
public function __construct()
{
$this->dateEtat = new \Datetime();
}
从版本4.4开始,当我执行POST或PUT时,会出现此错误
"type": "https://tools.ietf.org/html/rfc2616#section-10",
"title": "An error occurred",
"detail": "dateEtat: Cette valeur doit être de type string.",
"violations": [
{
"propertyPath": "dateEtat",
"message": "This value must be of type string."
}
]
见:
使用“Symfony\Component\Validator\Constraints\DateTime”验证\DateTime接口
自版本4.2以来已弃用
改用“Symfony\Component\Validator\Constraints\Type”
或者,如果基础模型已经是\DateTimeInterface提示的类型,则删除该约束
见:
使用“Symfony\Component\Validator\Constraints\DateTime”验证\DateTime接口
自版本4.2以来已弃用
改用“Symfony\Component\Validator\Constraints\Type”
或者,如果基础模型已经是\DateTimeInterface提示的类型,则删除该约束
谢谢你救了我一天谢谢!你救了我一天
"type": "https://tools.ietf.org/html/rfc2616#section-10",
"title": "An error occurred",
"detail": "dateEtat: Cette valeur doit être de type string.",
"violations": [
{
"propertyPath": "dateEtat",
"message": "This value must be of type string."
}
]