MultiUpload of files in Symfony 3.2

in #symfony6 years ago (edited)

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
        ]);
    }

Coin Marketplace

STEEM 0.18
TRX 0.14
JST 0.029
BTC 57610.17
ETH 3118.28
USDT 1.00
SBD 2.39