Published: 19 Jan 2018 › Updated: 19 Jan 2018

MultiUpload of files in Symfony 3.2
This helped tremendously:
https://github.com/marekz/example_symfony_multiply_files_example
This repo above mentioned here: https://stackoverflow.com/questions/41551183/upload-multiple-files-using-symfony-form/41551288
Only had to add this to config.yml:
# Doctrine Configuration
doctrine:
dbal:
server_version: '5.7'
otherwise I got:
[Doctrine\DBAL\Exception\DriverException]
An exception occured in driver: could not find driver
Removing __name__label__ from the data-prototype generated html code:
'entry_options' => array('label' => false)
which removes this __name__label__ from data-prototype which is then handled by the attached js to the symfony docs, which produces labels for added forms:
0label__
1label__
2label__
Form with CollectionType:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->setAction($options['action'])
->add('comment', TextareaType::class, [
'label' => 'request.form.labels.comment',
'required' => false
])
->add('swFiles', CollectionType::class, [
'entry_type' => FilesType::class,
'entry_options' => array('label' => false),
'label' => false,
'label' => 'request.form.labels.files',
'allow_add' => true,
'by_reference' => false
])
}
Form with what was entry_type above:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('file', FileType::class, [
'label' => false
]);
}
Leave MultiUpload of files in Symfony 3.2 to:
Read more #symfony posts
Best Posts From symfonydev
We have not curated any of symfonydev's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From symfonydev
- {@InheritDoc} plugin for PhpStorm
- How to implement a rollback feature
- Bug in behat 3.4.0 - No specifications found at path(s), This might be because of incorrect paths configuration in your `suites`.
- MultiUpload of files in Symfony 3.2
- Executing command line script for different environment (database)
- Validators in Symfony
- String encoding in php
- Command bus in Symfony
- Providing explicit UID (if the user is the same on client and host) at docker run will help with file permissions
- Check if there are the same values for given column