1
我有實體用戶和三個獨特的字段,並使用這個@UniqueEntity,但我不知道如何在消息可見確切已經在數據庫中的字段?我想,也許像斷言註釋Symfony Doctrine UniqueEntity repositoryMethod
* @Assert\Type(
* type="array",
* message="The value {{ value }} is not a valid {{ type }}."
*)
但不起作用
我的實體:
/**
* Users.
*
* @ORM\Table(name="users")
* @ORM\Entity(repositoryClass="Artel\ProfileBundle\Entity\UsersRepository")
* @ExclusionPolicy("all")
* @UniqueEntity(
* fields={"email", "telephone", "skype"},
* errorPath="entity",
* message="This email, telephone or skype is already."
*)
*/
class Users implements UserInterface
{
use Timestampable;
/**
* @var string
*
* @ORM\Column(name="email", type="string", length=255, unique=true, nullable=true)
* @Expose()
* @Assert\Length(min=3, max=255)
* @Assert\NotBlank()
* @Assert\Email()
*/
protected $email;
/**
* @var string
*
* @ORM\Column(name="skype", type="string", length=255, unique=true, nullable=true)
* @Assert\Length(min=3, max=255)
* @Expose()
*/
protected $skype;
/**
* @var string
*
* @ORM\Column(name="telephone", type="string", length=255, unique=true, nullable=true)
* @Assert\Length(min=3, max=255)
* @Expose()
*/
protected $telephone;
感謝,做工精細 –