I'm trying to set up a form with a FileType field with the multiple option enabled, but if I upload one by one, when submited it only sends the last one to the controller.
I would like to send every file that has been added to the input when submitted. Is there any way to send them?
My form field
class AnadirBarcoFotosForm extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('imagenes', FileType::class,[
'label' => false,
'multiple' => true,
'required' => false
])
->add('Guardar', SubmitType::class, [
'attr' => [
'class' => 'btn btn-secondary float-right boton-marron'
]
])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
]);
}
}
Controller
$paramAnadirBarcoFotos = array();
$anadirBarcoFotosForm = $this->createForm(AnadirBarcoFotosForm::class, $paramAnadirBarcoFotos);
$anadirBarcoFotosForm->handleRequest($request);
if ($anadirBarcoFotosForm->isSubmitted() && $anadirBarcoFotosForm->isValid()){
$datosAnadirBarcoFotos = $anadirBarcoFotosForm->getData();
...