KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've got a little problem with a Doctrine entity for a few days now. I've defined it with a UniqueConstraint on two fields with a UniqueEntity Validation on these two fields after that. But after validating of my form with a adding of an entity already in base, no way to obtain my error message in my form. Just an error message from Symfony : SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '339057986-00012' for key 'SIRET' Here is my entity declaration, all seems fine to me but maybe have I forgotten or misunderstood something? <?php namespace Proetco\FrontBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Validator\Constraints as Assert; /** * Proetco\FrontBundle\Entity\Entreprise * * @ORM\Table(name="entreprise", uniqueConstraints={@ORM\UniqueConstraint(name="SIRET", columns={"SIREN", "NIC"})}) * @ORM\Entity(repositoryClass="Proetco\FrontBundle\Entity\EntrepriseRepository") * @UniqueEntity(fields={"SIREN","NIC"}, message="Cette entreprise est déjà enregistrée") */ class Entreprise { protected $Siret; /** * @var integer $id * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string $SIREN * * @ORM\Column(name="SIREN", type="string", length=9) */ private $SIREN; /** * @var string $NIC * * @ORM\Column(name="NIC", type="string", length=5) */ private $NIC; /** * @var string $RS * * @ORM\Column(name="RS", type="string", length=45, nullable=true) */ private $RS; /** * @var string $NCOM * * @ORM\Column(name="NCOM", type="string", length=45, nullable=true) */ private $NCOM; /** * @var string $CPOS * * @ORM\Column(name="CPOS", type="string", length=5, nullable=true) */ private $CPOS; /** * @var string $LCOM * * @ORM\Column(name="LCOM", type="strin
Tags (comma-separated)
Save Edits
Cancel