If you set FOSUserBundle as your bundle's parent:
// src/Acme/UserBundle/AcmeUserBundle.php
<?php
namespace Acme\UserBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AcmeUserBundle extends Bundle
{
public function getParent()
{
return 'FOSUserBundle';
}
}
Then you can place your own validation.yml file in the config folder, and you can set the errorPath property of the unique constraint like this:
#validation.yml:
Acme\DemoBundle\Entity\User: # your user entity
constraints:
- Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity: { fields: usernameCanonical, errorPath: username, groups: [CustomRegistration, Default] }
Make sure you set errorPath as the actual field's name on your form.