Conversation

nacholibre

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.

@carsonbotcarsonbot added this to the 5.4 milestone Aug 8, 2023
@OskarStarkOskarStark requested a review from xabbuh August 14, 2023 08:12
@OskarStark

The explanation looks reasonable to me, WDYT @javiereguiluz ?

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

Successfully merging this pull request may close these issues.