Skip to content

Commit 81338b5

Browse files
committed
Merge branch '6.4' into 7.4
* 6.4: Fix File Upload Example
2 parents 4b2b009 + 1c85007 commit 81338b5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

controller/upload_file.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,13 @@ You can use the following code to link to the PDF brochure of a product:
217217
use Symfony\Component\HttpFoundation\File\File;
218218
// ...
219219

220-
$product->setBrochureFilename(
221-
new File($brochuresDirectory.DIRECTORY_SEPARATOR.$product->getBrochureFilename())
222-
);
220+
if (!$form->isSubmitted() && $product->getBrochureFilename()) {
221+
$form->setData(['brochure' => new File($this->getParameter('brochures_directory').DIRECTORY_SEPARATOR.$product->getBrochureFilename())]);
222+
}
223+
224+
if ($form->isSubmitted() && $form->isValid()) {
225+
// ...
226+
}
223227

224228
Creating an Uploader Service
225229
----------------------------

0 commit comments

Comments
 (0)