FilmType.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace App\Form;
  3. use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  4. use Symfony\Component\Form\Extension\Core\Type\TextType;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\Extension\Core\Type\DateType;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use Symfony\Component\OptionsResolver\OptionsResolver;
  9. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  10. class FilmType extends AbstractType
  11. {
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public function buildForm(FormBuilderInterface $builder, array $options)
  16. {
  17. $builder
  18. ->add('titre', TextType::class)
  19. ->add('annee', DateType::class, array(
  20. 'widget' => 'single_text',
  21. 'label' => 'Année',
  22. 'years' => range(1930, 2050, 1),
  23. 'html5' => false,
  24. 'format' => 'yyyy',
  25. 'required' => false
  26. ))
  27. ->add('lien', TextType::class, array(
  28. 'required' => false
  29. ))
  30. ->add('mediaVideo', MediaVideoType::class,array(
  31. 'required' => false,
  32. ))
  33. ->add('genres', CollectionType::class, array(
  34. 'entry_type' => GenreType::class,
  35. 'entry_options' => array('label'=>false),
  36. 'allow_add' => true,
  37. 'allow_delete' => true
  38. ))
  39. ->add('realisateurs', CollectionType::class, array(
  40. 'entry_type' => RealisateurType::class,
  41. 'entry_options' => array('label'=>false),
  42. 'allow_add' => true,
  43. 'allow_delete' => true,
  44. 'allow_extra_fields' => true
  45. ))
  46. ->add('save', SubmitType::class, array('label' => 'Enregistrer'));
  47. }
  48. /**
  49. * {@inheritdoc}
  50. */
  51. public function configureOptions(OptionsResolver $resolver)
  52. {
  53. $resolver->setDefaults(array(
  54. 'data_class' => 'App\Entity\Film'
  55. ));
  56. }
  57. /**
  58. * {@inheritdoc}
  59. */
  60. public function getBlockPrefix()
  61. {
  62. return 'App_film';
  63. }
  64. }