問題タブ [vichuploaderbundle]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票する
1 に答える
801 参照

symfony - Make file not nullable in VichUploaderBundle

I'm using VichUploaderBundle in my Symfony2.8 application to add file attribute to my entity. Please see code of entity below.

And everything works fine with one exception. I want to make filename not nullable. File has to be uploaded on creating entity and cannot be deleted during update. It can be only changed. Some file always has to be uploaded to entity. How to achieve this? If I add assert for filename like:

Then it not working, because during validating form, filename is empty. It is generated during persisting entity. But if I omit this assert, then it is possible to persist entity without uploading file.