src/Form/StudentType.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Student;
  4. use App\Entity\ClassRoom;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use Vich\UploaderBundle\Form\Type\VichImageType;
  8. use Symfony\Component\OptionsResolver\OptionsResolver;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Symfony\Component\Form\Extension\Core\Type\DateType;
  11. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  12. use Symfony\Component\Form\Extension\Core\Type\FileType;
  13. use Symfony\Component\Form\Extension\Core\Type\TextType;
  14. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  15. class StudentType extends AbstractType {
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public function buildForm(FormBuilderInterface $builder, array $options) {
  20. $builder->add('imageFile', VichImageType::class, [
  21. 'label' => 'Photo d identite(.jpg)',
  22. 'required' => false,
  23. 'allow_delete' => true,
  24. 'imagine_pattern' => 'student_filter_square_medium',
  25. 'download_uri' => false,
  26. ])
  27. ->add('matricule', TextType::class, [
  28. 'label' => 'Matricule',
  29. 'required' => true,
  30. 'constraints' => new Assert\NotBlank(),
  31. 'trim' => true])
  32. ->add('lastName', TextType::class, [
  33. 'label' => 'Nom',
  34. 'required' => true,
  35. 'constraints' => new Assert\NotBlank(),
  36. 'trim' => true])
  37. ->add('firstName', TextType::class, [
  38. 'label' => 'Prénom',
  39. 'required' => false,
  40. 'trim' => true])
  41. ->add('gender', ChoiceType::class, array(
  42. 'constraints' => new Assert\NotBlank(),
  43. 'choices' => array(
  44. 'FEMME' => '1',
  45. 'HOMME' => '0',
  46. ), 'label' => 'Sexe'))
  47. ->add('birthday', DateType::class, [
  48. 'label' => 'Date de naissance',
  49. 'widget' => 'single_text',
  50. 'required' => true,
  51. 'input' => 'datetime',
  52. 'html5' => true,
  53. 'attr' => ['class' => 'js-datepicker'],
  54. 'format' => 'yyyy-MM-dd',
  55. 'constraints' => new Assert\Date(),
  56. 'constraints' => new Assert\NotBlank(),
  57. 'trim' => true])
  58. ->add('birthplace',TextType::class, [
  59. 'label' => 'Lieu de naissance',
  60. 'required' => true,
  61. 'trim' => true])
  62. ->add('residence',TextType::class, [
  63. 'label' => 'Résidence',
  64. 'required' => false,
  65. 'trim' => true])
  66. ->add('fatherName', TextType::class, [
  67. 'label' => 'Nom du Père',
  68. 'required' => true,
  69. 'constraints' => new Assert\NotBlank(),
  70. 'trim' => true])
  71. ->add('motherName', TextType::class, [
  72. 'label' => 'Nom de la Mère',
  73. 'required' => true,
  74. 'constraints' => new Assert\NotBlank(),
  75. 'trim' => true])
  76. ->add('primaryContact',TextType::class, [
  77. 'label' => 'Contact du père ou tuteur',
  78. 'required' => false,
  79. 'trim' => true])
  80. ->add('secondaryContact',TextType::class, [
  81. 'label' => 'Contact de la mère ou nourrice',
  82. 'required' => false,
  83. 'trim' => true])
  84. ->add('particularDisease', TextType::class, [
  85. 'label' => 'Maladie(s) particulière(s)',
  86. 'required' => false,
  87. 'trim' => true])
  88. ->add('entryClass', EntityType::class, array('class' => ClassRoom::class, 'label' => 'Classe de depart', 'placeholder' => 'Choisir la classe', 'required' => false))
  89. ->add('otherInformations',TextType::class, [
  90. 'label' => 'Autres informations',
  91. 'required' => false,
  92. 'trim' => true])
  93. ;
  94. }
  95. /**
  96. * {@inheritdoc}
  97. */
  98. public function configureOptions(OptionsResolver $resolver) {
  99. $resolver->setDefaults(array(
  100. 'data_class' => Student::class,
  101. ));
  102. }
  103. /**
  104. * {@inheritdoc}
  105. */
  106. public function getName() {
  107. return 'student';
  108. }
  109. }