Skip to content

Commit 6093dd4

Browse files
committed
Tweaks
1 parent 8e7591a commit 6093dd4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

controller/upload_file.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ file contents.
4949
The next step is to add a new field to the form that manages the ``Product``
5050
entity. This must be a ``FileType`` field so the browsers can display the file
5151
upload widget. The trick to make it work is to add the form field as "unmapped",
52-
so Symfony doesn't try to get/set its value from the ``brochureFilename`` entity
53-
property::
52+
so Symfony doesn't try to get/set its value from the related entity::
5453

5554
// src/AppBundle/Form/ProductType.php
5655
namespace AppBundle\Form;
@@ -146,7 +145,7 @@ Finally, you need to update the code of the controller that handles the form::
146145
/** @var UploadedFile $brochureFile */
147146
$brochureFile = $form['brochure']->getData();
148147

149-
// this condition is required because the 'brochure' field is not required
148+
// this condition is needed because the 'brochure' field is not required
150149
// so the PDF file must be processed only when a file is uploaded
151150
if ($brochureFile) {
152151
$originalFilename = pathinfo($brochureFile->getClientOriginalName(), PATHINFO_FILENAME);
@@ -164,7 +163,7 @@ Finally, you need to update the code of the controller that handles the form::
164163
// ... handle exception if something happens during file upload
165164
}
166165

167-
// updates the 'brochure' property to store the PDF file name
166+
// updates the 'brochureFilename' property to store the PDF file name
168167
// instead of its contents
169168
$product->setBrochureFilename($newFilename);
170169
}

0 commit comments

Comments
 (0)