1

I'm dealing with something quite stupid here (I think).

I'm using PUGXMultiUserBundle in a Symfony2 project, but submitting a registration form (for each of my register form types) takes me back to the same form, and I don't know what I'm doing wrong.

Assuming I've followed "succesfully" steps 1..6 from PUGXMultiUserBundle documentation (https://github.com/PUGX/PUGXMultiUserBundle/blob/master/Resources/doc/index.md), and having the above stated behaviour... Where did I mess so badly?

*PUGXMultiUserBundle code and behaviour is spread along many files, I will provide the code you guys need to help to identify the issue, if we can circle it to a certain part.

Thanks in advance!

Manuel Gómez
  • 103
  • 1
  • 9
  • Ok, turns out it's not a bundle thing, more of a form render thing. When I render a {{ form_rest(form) }} at the end of my register template, it works well, but when I render a {{ form_widget(form._token) }} (and not the rest) it behaves like I explained. As I don't want to render all the fields from the form (I set the username after the email on the setEmail and setEmailCanonical methods, but it's not required for the users to input), this is such a problem for me. I will post another question here on SO. Thank you all. – Manuel Gómez Jan 15 '14 at 11:14
  • This is the new question: http://stackoverflow.com/questions/21136201/fosuserbundle-twig-form-submit-not-expected-behaviour Thanks. – Manuel Gómez Jan 15 '14 at 11:39

1 Answers1

0

1 Make sure you've setup the route correctly:

# Acme/UserBundle/Resources/config/routing.yml
user_one_registration:
    pattern:  /register/user-one
    defaults: { _controller: AcmeUserBundle:RegistrationUserOne:register }

user_two_registration:
    pattern:  /register/user-two
    defaults: { _controller: AcmeUserBundle:RegistrationUserTwo:register }

2 When you go at /register/user-one, you should see:

AcmeUserBundle:Registration:user_one.form.html.twig, and when you go at /register/user-two, you should see AcmeUserBundle:Registration:user_two.form.html.twig

3 And I have a feeling your error is in your template:

So, when you submit the form in your view, you have to submit it to the right method:

In AcmeUserBundle:Registration:user_one.form.html.twig:

<form action="{{ path('user_one_registration') }}" {{ form_enctype(form) }} method="POST">

In AcmeUserBundle:Registration:user_two.form.html.twig:

<form action="{{ path('user_two_registration') }}" {{ form_enctype(form) }} method="POST">
Mick
  • 30,759
  • 16
  • 111
  • 130
  • Thanks for the response. I got that part right, I think. Except for the fact that both actions (registerUserOneAction and registerUserTwoAction) live in the same controller. Could this be a problem? Otherwise i got it right. – Manuel Gómez Jan 15 '14 at 09:18
  • You need [two controllers](https://github.com/PUGX/PUGXMultiUserBundle/blob/master/Resources/doc/index.md#controllers) `RegistrationUserOneController` and `RegistrationUserTwoController`. Because this is the same method `register`. – Mick Jan 15 '14 at 09:20
  • Tried it, no luck. My routes looked like MyBundle:SameController:registerUserOne and MyBundle:SameController:registerUserTwo. Both actions were as documentation states. Still same issue. – Manuel Gómez Jan 15 '14 at 09:31
  • You need 2 controllers. – Mick Jan 15 '14 at 09:54
  • Thanks. Like I said, i've tried that, same result. I had one controller that featured registerUserOneAction() and registerUserTwoAction(), and the routing pointed to those methods. Then I changed it according to your response, two controllers, each with a registerAction() only. Routes pointing to those new controllers. The result is the same: Submit -> same form rendered -> database unaltered. – Manuel Gómez Jan 15 '14 at 10:03
  • 1
    Accepting @Patt 's answer, he hinted me about the form rendering "something" ;) – Manuel Gómez Jan 15 '14 at 11:15