src/Form/StudentType.php line 16

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