I have the current situation in a Symfony2 website:
login functionality performed by
loginActioninSecurityController. When visiting its route, the action uses parameters ( p1, p2, p3) while rendering the view. (same as FOSUserBundle)register functionnality
registerActioninRegistrationControlleris returning a view using other parameters p3,p4,p5. (same as FOSUserBundle)
Parameters are used to hold error messages when form is invalid.
I need to display a homepage that show both functionalities(a form for login and a form for registration), but that can also handle errors due to invalid data.
I can successfuly display the home page(MembersManagementBundle::index.html.twig):
{{ render(controller('MembersManagementBundle:Security:login')) }}
{{ render(controller('MembersManagementBundle:Registration:register')) }}
Controller:
class IndexController extends Controller
{
public function indexAction()
{
return $this->render('MembersManagementBundle::index.html.twig');
}
}
If good values are entered (whether in login or register form), redirection is performed to the correct target page after form submit.
But,
If bad data is entered to one of the forms, there is a redirection to its specific view with the specific errors( It is normal since submitting form calls the url specified in action attribute which call the corresponding action in corresponding controller).
Questions:
Is is possible to have the two actions in one template with the sum of all parameters? Should I develop indexAction so that it contains the logic of both actions? Or there is another way that can keep the two actions separate but merge the result into indexAction?
My goal at the end is to be able to generate index page with the needed errors(p1,p2,p3 or p4,p5,p6).
Thank you. Your help is much appreciated.