src/Form/BibliosType.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Biblios;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Symfony\Component\OptionsResolver\OptionsResolver;
  7. use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  8. class BibliosType extends AbstractType
  9. {
  10.     public function buildForm(FormBuilderInterface $builder, array $options)
  11.     {
  12.         $builder
  13.             ->add('title')
  14.             ->add('files',CollectionType::class,
  15.                 array(
  16.                     'label'     => false,
  17.                     'entry_type' => FileType::class,
  18.                     'prototype'            => true,
  19.                     'allow_add'            => true,
  20.                     'allow_delete'        => true,
  21.                     'by_reference'         => false,
  22.                     'entry_options'     => [
  23.                         'accept' => $options['accept'],
  24.                         'max-size' => $options['max-size'],
  25.                     ],
  26.                 )
  27.             )
  28.         ;
  29.     }
  30.     public function configureOptions(OptionsResolver $resolver)
  31.     {
  32.         $resolver->setDefaults([
  33.             'data_class' => Biblios::class,
  34.             'allow_extra_fields' => true,
  35.             'accept' => '*',
  36.             'max-size' => 0,
  37.         ]);
  38.     }
  39.     public function getBlockPrefix()
  40.     {
  41.         return 'os_biblio';
  42.     }
  43. }