Helper bundle for mapping Dropzone.js frontend to Symfony FormType using File entity
This bundle was heavily inspired by sopinet/UploadFilesBundle.
Make sure you have Oneup\UploaderBundle installed and configured
before you proceed.
See their documentation for
setting up this bundle.
Note: Make sure you enable orphanage management by setting the use_orphanage
configuration setting to true
.
Use composer to install the bundle
$ composer require curious-inc/file-upload-form-type-bundle
Register both OneUp/Uploader bundle and this bundle in AppKernel
// app/AppKernel.php
$bundles = [
...
new Oneup\UploaderBundle\OneupUploaderBundle(),
new CuriousInc\FileUploadFormTypeBundle\CuriousIncFileUploadFormTypeBundle(),
...
]
Edit your applications routing configuration
# /app/config/routing.yml
...
# Routing for CuriousInc FileUploadFormType bundle
curious_file_upload:
resource: '@CuriousIncFileUploadFormTypeBundle/Resources/config/routing.yml'
...
Edit your applications configuration file to reflect the following changes
Form configuration
# /app/config/config.yml
...
# Map template to FormType
twig:
form_themes:
- 'CuriousIncFileUploadFormTypeBundle:Form:file.html.twig'
...
Form configuration for SonataAdmin (if applicable)
# /app/config/config.yml
...
# Sonata DoctrineOrmAdmin template overrides
sonata_doctrine_orm_admin:
templates:
types:
list:
dropzone: '@CuriousIncFileUploadFormTypeBundle:Admin:file.html.twig'
...
show:
dropzone: '@CuriousIncFileUploadFormTypeBundle:Admin:file.html.twig'
...
...
OneUp/UploaderBundle configuration
# app/config/config.yml
...
# Configuration for oneup/uploader-bundle
oneup_uploader:
mappings:
gallery:
frontend: 'dropzone'
use_orphanage: true
namer: curious_file_upload.file_namer # needed
storage:
directory: '%kernel.project_dir%/web/uploads/gallery'
...