monsieurbiz / SyliusRichEditorPlugin

This plugin add a rich editor on fields to be able to drag and drop elements and edit it.
MIT License
65 stars 36 forks source link

Twig extension getCurrentFilePath throw exception (solved, need confirmation) #179

Open Loocos opened 2 years ago

Loocos commented 2 years ago

Hello there,

I want to know if my solution is the best regarding to your plugin. I've added a second image file type in the ImageType form. But after that, it throw an error 500 on the form validation if one of the two input image file type is empty/not set.

It come from the RichEditorExtension.php, twig filter function getCurrentFilePath because it's needed to return a string or a null but it's returning an object (UploadedFile)

So my solution is to add a is_object check and return null if true because the file/image isn't uploaded yet and we canno't get the right path : image

Is it a good solution for you @jacquesbh ? I can make a PR if that's good for you :)

Thanks