- //Last username entered by the user
- if ($lastUsername = $authenticationUtils->getLastUsername()) {
- $form->get('mail')->setData($lastUsername);
+ //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'
+ ]);
+
+ //Set mail from login form
+ $recover->get('mail')->setData($login->get('mail')->getData());
+
+ //Add recover error
+ $recover->addError(new FormError(
+ $this->translator->trans('Use this form to recover your account')
+ ));
+
+ //Add recover form to context
+ $context['recover'] = $recover->createView();