- $form->get('mail')->addError(new FormError($error));
- }
-
- //Last username entered by the user
- if ($lastUsername = $authenticationUtils->getLastUsername()) {
- $form->get('mail')->setData($lastUsername);
+ $login->get('mail')->addError(new FormError($error));
+
+ //Create the RecoverType form and give the proper parameters
+ $recover = $this->createForm($this->config['recover']['view']['form'], null, [
+ //Set action to recover route name and context
+ 'action' => $this->generateUrl($this->config['route']['recover']['name'], $this->config['route']['recover']['context']),
+ 'method' => 'POST'
+ ]);
+
+ //Get recover mail entity
+ $recover->get('mail')
+ //Set mail from login form
+ ->setData($login->get('mail')->getData())
+ //Add recover error
+ ->addError(new FormError($this->translator->trans('Use this form to recover your account')));
+
+ //Add recover form to context
+ $context['recover'] = $recover->createView();