src/Form/StudentType.php line 19

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 or PNG)'
  22.                         'required' => false,
  23.                         'allow_delete' => true,
  24.                         'imagine_pattern' => 'student_filter_square_medium',
  25.                         'download_uri' => false,
  26.                         
  27.                     ])
  28.                /* ->add('matricule', TextType::class, [
  29.                         'label' => 'Matricule',
  30.                         'required' => true,
  31.                         'constraints' => new Assert\NotBlank(),
  32.                         'trim' => true])*/
  33.                 ->add('lastName'TextType::class, [
  34.                     'label' => 'Nom',
  35.                     'required' => true,
  36.                     'constraints' => new Assert\NotBlank(),
  37.                     'trim' => true])
  38.                 ->add('firstName'TextType::class, [
  39.                     'label' => 'Prénom',
  40.                     'required' => false,
  41.                     'trim' => true])
  42.                 ->add('gender'ChoiceType::class, array(
  43.                     'constraints' => new Assert\NotBlank(),
  44.                     'choices' => array(
  45.                         'FEMME' => '1',
  46.                         'HOMME' => '0',
  47.                     ), 'label' => 'Sexe'))
  48.                 ->add('birthday'DateType::class, [
  49.                     'label' => 'Date de naissance',
  50.                     'widget' => 'single_text',
  51.                     'required' => true,
  52.                      'input' => 'datetime',
  53.                     'html5' => true,
  54.                     'attr' => ['class' => 'js-datepicker'],
  55.                     'format' => 'yyyy-MM-dd',
  56.                     'constraints' => new Assert\Date(),
  57.                     'constraints' => new Assert\NotBlank(),
  58.                     'trim' => true])
  59.                 
  60.                 ->add('birthplace',TextType::class, [
  61.                     'label' => 'Lieu de naissance',
  62.                     'required' => true,
  63.                  
  64.                     'trim' => true])
  65.                 ->add('residence',TextType::class, [
  66.                     'label' => 'Résidence',
  67.                     'required' => false,
  68.                     'trim' => true])
  69.                 ->add('fatherName'TextType::class, [
  70.                     'label' => 'Nom du Père',
  71.                     'required' => true,
  72.                     'constraints' => new Assert\NotBlank(),
  73.                     'trim' => true])
  74.                 ->add('motherName'TextType::class, [
  75.                     'label' => 'Nom de la Mère',
  76.                     'required' => true,
  77.                     'constraints' => new Assert\NotBlank(),
  78.                     'trim' => true])
  79.                 ->add('primaryContact',TextType::class, [
  80.                     'label' => 'Contact du père ou tuteur',
  81.                     'required' => false,
  82.                     'trim' => true])
  83.                 ->add('secondaryContact',TextType::class, [
  84.                     'label' => 'Contact de la mère ou nourrice',
  85.                     'required' => false,
  86.                     'trim' => true])
  87.                 
  88.                 ->add('particularDisease'TextType::class, [
  89.                     'label' => 'Maladie(s) particulière(s)',
  90.                     'required' => false,
  91.                     'trim' => true])
  92.                 ->add('entryClass'EntityType::class, array('class' => ClassRoom::class, 'label' => 'Classe de depart''placeholder' => 'Choisir la classe''required' => false))
  93.                 ->add('otherInformations',TextType::class, [
  94.                     'label' => 'Autres informations',
  95.                     'required' => false,
  96.                     'trim' => true])
  97.         ;
  98.     }
  99.     /**
  100.      * {@inheritdoc}
  101.      */
  102.     public function configureOptions(OptionsResolver $resolver) {
  103.         $resolver->setDefaults(array(
  104.             'data_class' => Student::class,
  105.         ));
  106.     }
  107.     /**
  108.      * {@inheritdoc}
  109.      */
  110.     public function getName() {
  111.         return 'student';
  112.     }
  113. }