Avatar ·

How to set a default value for an entity field in Doctrine?

Hi everyone! I'm just starting to learn Doctrine ORM in Symfony, and I'm having trouble setting a default value for one of the entity fields. I have a `User` entity, and I want the `status` field to have a default value of `'active'`. Here's how I tried to do it: ```php /** * @ORM\Entity(repositoryClass=UserRepository::class) */ class User { /** * @ORM\Column(type="string", length=20, options={"default": "active"}) */ private $status; } ``` But when I create a new user without specifying the status: ```php $user = new User(); $em->persist($user); $em->flush(); ``` The `status` field remains `null` instead of `'active'`. I expected Doctrine to automatically set the default value when saving. I've read the docum