Describe the bug
Hello,
My User entity contains several properties including a string type email.
However, when I modify a user, I get an error message that says that the type must be Array | IteratorAggregate.
Is this a problem with my entity or rather an EasyAdmin type problem?
I searched quite a bit on the internet but I couldn't find any solution, I don't understand the origin of this behaviour.
Precision: I let EasyAdmin manage the type, I don't have a custom type for the User entity.
To Reproduce
(OPTIONAL) Additional context
App\User.php :
<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @UniqueEntity("mail")
* @UniqueEntity("psn")
* @ORM\Table(name="`user`")
*/
class User implements UserInterface
{
/**
* @ORM\Column(type="string", length=255, unique=true)
* @Assert\Unique
* @Assert\Email
* @Assert\NotBlank
*/
private $mail;
// ...
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUsername(): string
{
return (string) $this->mail;
}
public function getMail(): ?string
{
return $this->mail;
}
public function setMail(string $mail): self
{
$this->mail = $mail;
return $this;
}
public function __toString(): string
{
return (string) $this->mail;
}
}

Your email property looks correct ... so I can't understand how this can fail ... and why that specific error shows. It dones't make sense to me 馃槓
test remove the
* @Assert\Unique
* @Assert\Email
* @Assert\NotBlank
works ???
test remove the
* @Assert\Unique * @Assert\Email * @Assert\NotBlank
works ???
Indeed, this is working again !
It was a problem of my entity, not EasyAdmin, I'm sorry.
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @UniqueEntity("mail")
* @UniqueEntity("psn")
* @ORM\Table(name="`user`")
*/
class User implements UserInterface
{
/**
* @ORM\Column(type="string", length=255, unique=true)
* @Assert\Unique
* @Assert\Email
* @Assert\NotBlank
*/
private $mail;
}
You can't have UniqueEntity and @Assert\Unique in the same time, this doesn't make any sense to have the both.
Thank you
Most helpful comment
test remove the
* @Assert\Unique * @Assert\Email * @Assert\NotBlankworks ???