There are 2 solutions.
Quick and dirty (Symfony < 5)
Change this in config/packages/easy_admin.yaml
:
easy_admin:
entities:
MyEntity:
form:
fields:
- { property: 'birthday', type: 'date' }
See https://symfony.com/doc/master/bundles/EasyAdminBundle/book/edit-new-configuration.html#the-special-form-view for further configuration details.
Quick and clean
@Assert\Date()
will be deprecated for type="date"
fields in Symfony 4.2 (and thus probably removed in Symfony 5). The validation relies on the \DateTimeInterface
type hint of the setter. In total:
/**
* @ORM\Column(type="date")
* @Assert\NotBlank()
*/
private $birthday;
public function setBirthday(?\DateTimeInterface $birthday): self
{
// ...
return $this;
}
See https://github.com/EasyCorp/EasyAdminBundle/issues/2381 for some background information.