Reputation: 620
What do I have to enter in the annotation of a doctrine entity.
Its actually like this...
/**
* @ORM\Column(type="string", length=255)
*
* @Assert\Length(
* min=3,
* max=255,
* minMessage="The name is too short.",
* maxMessage="The name is too long.",
* groups={"Registration", "Profile"}
* )
*/
protected $name;
I have to tell doctrine something like canBeNull=true
. Otherwhise I always get this error SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null
But whats the code?
Upvotes: 1
Views: 3002
Reputation: 2413
Define the attribute nullable in the COLUMN property with true.
Example:
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Assert\Length(
* min=3,
* max=255,
* minMessage="The name is too short.",
* maxMessage="The name is too long.",
* groups={"Registration", "Profile"}
* )
*/
protected $name;
Upvotes: 9