There is a form sent via POST. We fill it with incorrect values, the data does not pass validation, the result is displayed to the user. Then we fill it with the correct values ​​and send it, the answer will be the file. Save it, the page after the download is not updated. If you then forcibly refresh the page, the browser will offer to resubmit the form, agree - in POST there will be data from the previous request, filled with values ​​that have not been validated. How to get around?

  • How do you force a page refresh? - Connor Holt
  • one
    Reset the post data with a redirect. > header ("Location:". "http: //".> $ _SERVER ['HTTP_HOST']. $ location) - erbolking
  • @erbolking, and such a header does not prevent downloading the file? - IVsevolod
  • Tried, interferes. - Andrey Talanin September

3 answers 3

Try to add to your check add to your check.

if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($info); $em->flush(); --> return $this->redirectToRoute('contact'); <--(на эту же страницу) } 

    Try to clean the fields using JavaScript immediately after submitting the form.

      1) Do the redirect at the very end: header("Location: Ваш URL");

      2) If you can use Javascript, then AJAX will be just.