I migrated a project from Symfony 3.4 to Symfony 4.4 (back side with API platform)
In an entity I have a date field, which is automatically generated on today's date, So when I make a POST or a PUT, she is not in my JSON
/**
* @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 getDateEtat(): ?\DateTimeInterface
{
return $this->dateEtat;
}
public function setDateEtat(?\DateTimeInterface $dateEtat): self
{
$this->dateEtat = $dateEtat;
return $this;
}
and a construct :
public function __construct()
{
$this->dateEtat = new \Datetime();
}
since version 4.4 when I do a POST or a PUT, I get this error
"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."
}
]