src/Form/EvaluationType.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Sequence;
  4. use App\Entity\ClassRoom;
  5. use App\Entity\Evaluation;
  6. use App\Repository\SequenceRepository;
  7. use Symfony\Component\Form\AbstractType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. use Symfony\Component\Form\Extension\Core\Type\TextType;
  12. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  13. class EvaluationType extends AbstractType
  14. {
  15.     private $repo;
  16.     public function __construct(SequenceRepository $scRepo)
  17.     {
  18.         $this->repo $scRepo;
  19.     }
  20.     public function buildForm(FormBuilderInterface $builder, array $options): void
  21.     {
  22.         $builder
  23.             
  24.         ->add('sequence'EntityType::class, array('class' => Sequence::class,'data' => $options['activated_sequence'], 'placeholder' => 'Choisir la séquence''required' => true,'query_builder' => function (SequenceRepository $repository) {
  25.                 return $repository->createQueryBuilder('s')->leftJoin('s.quater''q')->leftJoin('q.schoolYear''sc') ->where('sc.activated = :rep')->setParameter('rep'true)->add('orderBy''s.id');
  26.              } ))
  27.          ->add('classRoom'EntityType::class, array('placeholder' => 'Choisir une classe','class' => ClassRoom::class, 'required' => true ))
  28.          ->add('competence',TextType::class, [
  29.             'label' => 'Competence',
  30.             'required' => false,
  31.             'trim' => true])
  32.         ;
  33.     }
  34.     public function configureOptions(OptionsResolver $resolver): void
  35.     {
  36.         $resolver->setDefaults([
  37.             'data_class' => Evaluation::class,
  38.             'activated_sequence' => $this->repo->findOneBy(array("activated" => true))
  39.         ]);
  40.     }
  41. }