Hello everyone I still learning symfony2 and I want to handle uploading multiple files to server. I try execute 2 entities by one form. I have Document, Product entity and
form CreateProductType:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', 'text') // product name, quantity, description, etc
->add('file','file',array(
'required' => false,
'mapped' => false,
'data_class' => 'AppBundle\Entity\Document',
'attr' => array(
'accept' => 'image/*',
'multiple' => 'multiple',
)
));
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\Product'
));
}
what I supposed to do in controller to put files to uploads folder, insert new product
name,description,quantity,price, etc
and document (photos)
id, path, product_id
to database? Thanks in advance.
EDIT. my Document entity looks like this Document.php