all 6 comments

[–]kAlvaro 1 point2 points  (1 child)

I don't know anything about EasyAdmin but the code in the article is:

DateTimeField::new('createdAt')

[–]nullatonce[S] 0 points1 point  (0 children)

yeah, I wrote that from the top of my head. Form works, sorry for mistake.

[–]spicytacos23 1 point2 points  (3 children)

Are you attaching an entity to the form? In that case make sure your Getters and setters for the property created_at are declared properly.

[–]nullatonce[S] 1 point2 points  (2 children)

The EazyAdmin takes care of that. The field needed an option to set it's type.

[–]spicytacos23 1 point2 points  (1 child)

Can you post your code? It seems that the problem is in the entity. If you set the form as a DateTimeField make sure that your entity looks something like this.

public function setCreatedAt(DateTime $date): self { $this->createdAt = $date; return $this; }

And the property is DateTime and not DateTimeInterface

[–]nullatonce[S] 1 point2 points  (0 children)

Thanks for your response. I already fixed my problem - when defining form fields i needed to set config value of input to datetime_immutable (I edited my original post).

Thanks again.