I am using the latest versions of FOSUserBundle and Symfony2. I have to provide a form that can be used for login and registration.
and two buttons:
If the user clicks his mail address and login, he will get an error which is missing the password. If he enters his mail address and click register, he gets an account and a password is generated. I have already implemented the entire functionality, but I use two different forms for login and register.
Now I want to merge these forms. I have tried to overcome this so:
public function welcomeaction () {$ data = array (); $ Form = $ this- & gt; CreateFormbuilder ($ data) - & gt; Add ("Email", "Email") - & gt; Add ("password", "password", array ("required" => incorrect)) - & gt; Add ("Register", "Submit") - & gt; Add ("Login", "Submit") - & gt; GetForm (); $ Form & gt; HandleRequest ($ this-> getRequest ()); If ($ form-> isValid ()) {if ($ form-> get ("login") -> isClicked ()) {back to $$ -> return it ('FOSUserBundle: Security: check ', array (' _username '= & gt; $ form- & gt; getData () ["email"],' _password '=> $ form-> getData () ["password"] )); } And if ($ form-> get ("register") -> isClicked ()) {echo "rge"; #testing} and die ("ERROR_WELCOME_FORM"); } $ $ Returned - ('MyBundle: Index: welcome.html.twig'), array ("form" => gt; form- & gt; createView ()); }
It is not possible to forward for forwarding instead of redirecting because
whenever I click the login button:
You must configure the check path in your security firewall configuration to manage the firewall by using form_login.
So I changed the check_path parameter in security .ml
check_path: fos_user_security_check
for
Check_path: Welcome (this is my route for index: Welcome
And then double check it. Now with the new check_path it is because the original fos_user_security_check was deleted, obviously but I have both merged form and single form Need to use.
Other Yes, I get an error
Invalid CSRF-Token.
Does anyone have the solution? Is it possible that hacking in focus bundle Or can the log action be applied by hand? I want only one for the register part of the form, but I think it is analog.
Is this a wrong approach? Do I give it somehow Can I use the same field (email) for different forms?
Comments
Post a Comment