0

If I override register.html.twig from FOSUserBundle, registration does work properly but when a duplicated username or email is entered, instead of showing an error message I get a UniqueConstraintViolationException.

I saw this solution but it doesn't actually work for me, maybe to old?

Symfony2 FOSUserBundle extending registration form causes duplicate email to validate

I'm not overriding RegistrationController so far as registration process doen't require any extra functionality.

This is my register.html.twig template:

{% extends "FOSUserBundle::layout.html.twig" %}
{% block fos_user_content %}
    {{ form_start(form, {'method': 'post', 'action': path('fos_user_registration_register'), 'attr': {'class': 'fos_user_registration_register'}}) }}
        {{ form_row(form.username, {'label': 'Username:', 'attr': {'placeholder': 'mail@example.com'}}) }}
        {{ form_row(form.name) }}
        {{ form_row(form.plainPassword) }}
        {{ form_rest(form) }}
        <input type="submit" value="Register" />
    {{ form_end(form) }}
{% endblock fos_user_content %}

My versions:

"symfony/symfony": "3.4.*",
"friendsofsymfony/user-bundle": "2.1.*",
K. Weber
  • 2,643
  • 5
  • 45
  • 77
  • Please add symfony version and fosuser version being used, possibly from your composer.lock – Jan Myszkier Feb 20 '19 at 13:37
  • Why did the linked solution not work for you? Did you still get the exception? Did you clear caches in between tries? – dbrumann Feb 20 '19 at 14:52
  • The solution I linked has no effect at all, I still get the same exception (as I remark I try to avoid to overrwrite controller so my use case is not exactly as that solution, but the validator should work anyway). And yes, cache was cleared. – K. Weber Feb 20 '19 at 15:03

0 Answers0