src/Form/AlbumsType.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Albums;
  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 AlbumsType extends AbstractType
  9. {
  10.     public function buildForm(FormBuilderInterface $builder, array $options)
  11.     {
  12.         $builder
  13.             ->add('title')
  14.             ->add('pictures',CollectionType::class,
  15.                 array(
  16.                     'label'     => false,
  17.                     'entry_type' => PictureType::class,
  18.                     'allow_add'            => true,
  19.                     'allow_delete'        => true,
  20.                     'prototype'            => true,
  21.                     'by_reference'         => false,
  22.                     'entry_options'     => [
  23.                         'accept' => $options['accept'],
  24.                         'max-size' => $options['max-size'],
  25.                         'min-width' => $options['min-width'],
  26.                         'min-height' => $options['min-height'],
  27.                     ],
  28.                 )
  29.             )
  30.         ;
  31.     }
  32.     public function configureOptions(OptionsResolver $resolver)
  33.     {
  34.         $resolver->setDefaults([
  35.             'data_class' => Albums::class,
  36.             'allow_extra_fields' => true,
  37.             'accept' => 'image/*',
  38.             'max-size' => 0,
  39.             'min-width' => 0,
  40.             'min-height' => 0,
  41.         ]);
  42.     }
  43.     public function getBlockPrefix()
  44.     {
  45.         return 'os_album';
  46.     }
  47. }