1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace App\Form;
- use App\Entity\Film;
- use Symfony\Component\Form\Extension\Core\Type\CollectionType;
- use Symfony\Component\Form\Extension\Core\Type\TextType;
- use Symfony\Component\Form\Extension\Core\Type\TextareaType;
- use Symfony\Component\Form\AbstractType;
- use Symfony\Component\Form\Extension\Core\Type\DateType;
- use Symfony\Component\Form\FormBuilderInterface;
- use Symfony\Component\OptionsResolver\OptionsResolver;
- use Symfony\Component\Form\Extension\Core\Type\SubmitType;
- class FilmType extends AbstractType
- {
- /**
- * {@inheritdoc}
- */
- public function buildForm(FormBuilderInterface $builder, array $options): void
- {
- $builder
- ->add('titre', TextType::class)
- ->add('annee', DateType::class, array(
- 'widget' => 'single_text',
- 'label' => 'Année',
- 'years' => range(1930, 2050, 1),
- 'html5' => false,
- 'format' => 'yyyy',
- 'required' => false
- ))
- ->add('lien', TextType::class, array(
- 'required' => false
- ))
- ->add('mediaVideos', CollectionType::class, [
- 'entry_type' => MediaVideoType::class,
- 'entry_options' => array('label'=>false),
- 'allow_add' => true,
- 'allow_delete' => true,
- 'by_reference' => false
- ])
- ->add('dateSortie', DateType::class, [
- 'input' => 'datetime_immutable',
- 'html5' => true,
- 'widget' => 'single_text',
- 'required' => false
- ])
- ->add('information', TextareaType::class, [
- 'required' => false,
- 'attr' => [
- 'rows' => 5
- ]
- ])
- ->add('genres', CollectionType::class, [
- 'entry_type' => GenreType::class,
- 'entry_options' => array('label'=>false),
- 'allow_add' => true,
- 'allow_delete' => true
- ])
- ->add('realisateurs', CollectionType::class, [
- 'entry_type' => RealisateurType::class,
- 'entry_options' => array('label'=>false),
- 'allow_add' => true,
- 'allow_delete' => true,
- 'allow_extra_fields' => true
- ])
- ->add('save', SubmitType::class, array('label' => 'Enregistrer'));
- }
-
- /**
- * {@inheritdoc}
- */
- public function configureOptions(OptionsResolver $resolver): void
- {
- $resolver->setDefaults([
- 'data_class' => Film::class
- ]);
- }
- /**
- * {@inheritdoc}
- */
- public function getBlockPrefix() : string
- {
- return 'App_film';
- }
- }
|