Skip to content

Conversation

nacholibre
Copy link
Contributor

@nacholibre nacholibre commented Aug 8, 2023

Currently the example suggests to execute this code when doing edit

$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.

@carsonbot carsonbot added this to the 5.4 milestone Aug 8, 2023
@OskarStark OskarStark requested a review from xabbuh August 14, 2023 08:12
@OskarStark
Copy link
Contributor

The explanation looks reasonable to me, WDYT @javiereguiluz ?

@xabbuh xabbuh modified the milestones: 5.4, 6.4 Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants