Commit 1c85007
committed
minor #18722 [Form] Fix File Upload Example (nacholibre)
This PR was submitted for the 5.4 branch but it was merged into the 6.4 branch instead.
Discussion
----------
[Form] Fix File Upload Example
Currently the example suggests to execute this code when doing edit
```php
$product->setBrochureFilename(
new File($this->getParameter('brochures_directory').'/'.$product->getBrochureFilename())
);
```
this is wrong in couple of ways
First the `setBrochureFilename` method expects string and not a `File` instance. No error is thrown because the `File` instance can be casted to `string` and will return the full path, which is not what's needed. In the database field you need to store the filename only, and not the full path.
Second the form expects `File` instance and not the entity. This is why the form data needs to be changed and not the entity.
In the 4.4 branch it's the same.
Commits
-------
e2fb274 Fix File Upload Example1 file changed
+7
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | | - | |
210 | | - | |
211 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
212 | 216 | | |
213 | 217 | | |
214 | 218 | | |
| |||
0 commit comments