From 528a54619f835766dc8930ded1b387fe42533b5d Mon Sep 17 00:00:00 2001 From: Yoan Arnaudov Date: Tue, 8 Aug 2023 12:11:37 +0300 Subject: [PATCH] Fix File Upload Example --- controller/upload_file.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/controller/upload_file.rst b/controller/upload_file.rst index 886c772d98a..2d6ad260491 100644 --- a/controller/upload_file.rst +++ b/controller/upload_file.rst @@ -222,9 +222,13 @@ You can use the following code to link to the PDF brochure of a product: use Symfony\Component\HttpFoundation\File\File; // ... - $product->setBrochureFilename( - new File($this->getParameter('brochures_directory').'/'.$product->getBrochureFilename()) - ); + if (!$form->isSubmitted() && $product->getBrochureFilename()) { + $form->setData(['brochure' => new File($this->getParameter('brochures_directory').'/'.$product->getBrochureFilename())]); + } + + if ($form->isSubmitted() && $form->isValid()) { + // ... + } Creating an Uploader Service ---------------------------- pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy