]> Raphaël G. Git Repositories - airbundle/commitdiff
Fix buildForm to match upstream prototype and return value
authorRaphaël Gertz <git@rapsys.eu>
Thu, 3 Dec 2026 02:59:45 +0000 (03:59 +0100)
committerRaphaël Gertz <git@rapsys.eu>
Thu, 3 Dec 2026 02:59:45 +0000 (03:59 +0100)
Fix NotBlank, Email and File constraint new constructor prototype

Form/ApplicationType.php
Form/ContactType.php
Form/DisputeType.php
Form/ImageType.php
Form/LocationType.php
Form/SessionType.php
Form/SnippetType.php

index f52ad8c46709c1ed2b0addababe2089240ac3146..6c6397d4cfb43530b779dfd0777ee0ee75bce741 100644 (file)
@@ -34,21 +34,21 @@ class ApplicationType extends AbstractType {
         */
        public function buildForm(FormBuilderInterface $builder, array $options): void {
                //Add dance field
-               $builder->add('dance', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Dance', 'choices' => $options['dance_choices'], 'preferred_choices' => $options['dance_favorites'], 'attr' => ['placeholder' => 'Your dance'], 'choice_translation_domain' => true, 'constraints' => [new NotBlank(['message' => 'Please provide your dance'])], 'data' => $options['dance_default']]);
+               $builder->add('dance', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Dance', 'choices' => $options['dance_choices'], 'preferred_choices' => $options['dance_favorites'], 'attr' => ['placeholder' => 'Your dance'], 'choice_translation_domain' => true, 'constraints' => [new NotBlank(null, 'Please provide your dance')], 'data' => $options['dance_default']]);
 
                //Add date field
-               $builder->add('date', DateType::class, ['attr' => ['placeholder' => 'Your date', 'class' => 'date'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'format' => 'yyyy-MM-dd', 'data' => new \DateTime('+7 day'), 'constraints' => [new NotBlank(['message' => 'Please provide your date']), new Type(['type' => \DateTime::class, 'message' => 'Your date doesn\'t seems to be valid'])]]);
+               $builder->add('date', DateType::class, ['attr' => ['placeholder' => 'Your date', 'class' => 'date'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'format' => 'yyyy-MM-dd', 'data' => new \DateTime('+7 day'), 'constraints' => [new NotBlank(null, 'Please provide your date'), new Type(['type' => \DateTime::class, 'message' => 'Your date doesn\'t seems to be valid'])]]);
 
                //Add location field
-               $builder->add('location', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Location', 'choices' => $options['location_choices'], 'preferred_choices' => $options['location_favorites'], 'attr' => ['placeholder' => 'Your location'], 'choice_translation_domain' => true, 'constraints' => [new NotBlank(['message' => 'Please provide your location'])], 'data' => $options['location_default']]);
+               $builder->add('location', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Location', 'choices' => $options['location_choices'], 'preferred_choices' => $options['location_favorites'], 'attr' => ['placeholder' => 'Your location'], 'choice_translation_domain' => true, 'constraints' => [new NotBlank(null, 'Please provide your location')], 'data' => $options['location_default']]);
 
                //Add slot field
-               $builder->add('slot', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Slot', 'attr' => ['placeholder' => 'Your slot'], 'constraints' => [new NotBlank(['message' => 'Please provide your slot'])], 'choice_translation_domain' => true, 'data' => $options['slot_default']]);
+               $builder->add('slot', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Slot', 'attr' => ['placeholder' => 'Your slot'], 'constraints' => [new NotBlank(null, 'Please provide your slot')], 'choice_translation_domain' => true, 'data' => $options['slot_default']]);
 
                //Add extra user field
                if (!empty($options['user'])) {
                        //XXX: choicetype used here to use our own custom translated string
-                       $builder->add('user', ChoiceType::class, ['attr' => ['placeholder' => 'Your user'], 'choice_translation_domain' => false, 'constraints' => [new NotBlank(['message' => 'Please provide your user'])], 'choices' => $options['user_choices'], 'data' => $options['user_default']]);
+                       $builder->add('user', ChoiceType::class, ['attr' => ['placeholder' => 'Your user'], 'choice_translation_domain' => false, 'constraints' => [new NotBlank(null, 'Please provide your user')], 'choices' => $options['user_choices'], 'data' => $options['user_default']]);
                }
 
                //Add submit
index 4142c996d4c0bc3dcdcf8a3d13b8c7ffba8f8a7a..2b8dd744c237ccda2bf9eab9270472423261fec0 100644 (file)
@@ -32,10 +32,10 @@ class ContactType extends CaptchaType {
        public function buildForm(FormBuilderInterface $builder, array $options): void {
                //Add fields
                $builder
-                       ->add('name', TextType::class, ['attr' => ['placeholder' => 'Your name'], 'constraints' => [new NotBlank(['message' => 'Please provide your name'])]])
-                       ->add('subject', TextType::class, ['attr' => ['placeholder' => 'Subject'], 'constraints' => [new NotBlank(['message' => 'Please provide your subject'])]])
-                       ->add('mail', EmailType::class, ['attr' => ['placeholder' => 'Your mail'], 'constraints' => [new NotBlank(['message' => 'Please provide a valid mail']), new Email(['message' => 'Your mail doesn\'t seems to be valid'])]])
-                       ->add('message', TextareaType::class, ['attr' => ['placeholder' => 'Your message', 'cols' => 50, 'rows' => 15], 'constraints' => [new NotBlank(['message' => 'Please provide your message'])]])
+                       ->add('name', TextType::class, ['attr' => ['placeholder' => 'Your name'], 'constraints' => [new NotBlank(null, 'Please provide your name')]])
+                       ->add('subject', TextType::class, ['attr' => ['placeholder' => 'Subject'], 'constraints' => [new NotBlank(null, 'Please provide your subject')]])
+                       ->add('mail', EmailType::class, ['attr' => ['placeholder' => 'Your mail'], 'constraints' => [new NotBlank(null, 'Please provide a valid mail'), new Email(null, 'Your mail doesn\'t seems to be valid')]])
+                       ->add('message', TextareaType::class, ['attr' => ['placeholder' => 'Your message', 'cols' => 50, 'rows' => 15], 'constraints' => [new NotBlank(null, 'Please provide your message')]])
                        ->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]);
 
                //Call parent
index 4bf9285d32b364e2982366de213d9feb4c19b3d8..77dbffa94bbcb63d5b3862b38c93e8f68c0ebc73 100644 (file)
@@ -17,11 +17,11 @@ class DisputeType extends AbstractType {
         */
        public function buildForm(FormBuilderInterface $builder, array $options) {
                return $builder
-                       ->add('offense', ChoiceType::class, ['choices' => ['Forbidden gathering' => 'gathering', 'Traffic at prohibited time' => 'traffic'/*, 'Traffic at prohibited location' => 'location'*/], 'attr' => ['placeholder' => 'Your offense'], 'constraints' => [new NotBlank(['message' => 'Please provide your offense'])]])
-                       ->add('court', TextType::class, ['label' => 'Court city', 'attr' => ['placeholder' => 'Your court city'], 'constraints' => [new NotBlank(['message' => 'Please provide your court city'])]])
-                       ->add('notice', TextType::class, ['label' => 'Notice number', 'attr' => ['placeholder' => 'Your notice number'], 'constraints' => [new NotBlank(['message' => 'Please provide your notice'])]])
-                       ->add('agent', TextType::class, ['label' => 'Agent number', 'attr' => ['placeholder' => 'Your agent number'], 'constraints' => [new NotBlank(['message' => 'Please provide your agent'])]])
-                       ->add('service', TextType::class, ['label' => 'Service code', 'attr' => ['placeholder' => 'Your service code'], 'constraints' => [new NotBlank(['message' => 'Please provide your service'])]])
+                       ->add('offense', ChoiceType::class, ['choices' => ['Forbidden gathering' => 'gathering', 'Traffic at prohibited time' => 'traffic'/*, 'Traffic at prohibited location' => 'location'*/], 'attr' => ['placeholder' => 'Your offense'], 'constraints' => [new NotBlank(null, 'Please provide your offense')]])
+                       ->add('court', TextType::class, ['label' => 'Court city', 'attr' => ['placeholder' => 'Your court city'], 'constraints' => [new NotBlank(null, 'Please provide your court city')]])
+                       ->add('notice', TextType::class, ['label' => 'Notice number', 'attr' => ['placeholder' => 'Your notice number'], 'constraints' => [new NotBlank(null, 'Please provide your notice')]])
+                       ->add('agent', TextType::class, ['label' => 'Agent number', 'attr' => ['placeholder' => 'Your agent number'], 'constraints' => [new NotBlank(null, 'Please provide your agent')]])
+                       ->add('service', TextType::class, ['label' => 'Service code', 'attr' => ['placeholder' => 'Your service code'], 'constraints' => [new NotBlank(null, 'Please provide your service')]])
                        ->add('abstract', TextareaType::class, ['attr' => ['placeholder' => 'Your abstract', 'cols' => 50, 'rows' => 15], 'constraints' => []])
                        ->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]);
        }
index 300ffe9e0ca1ad80e2f4d416acc94b91dcf2af22..612adea9f2a60e22d2ee07388d6500253965c4ab 100644 (file)
@@ -26,7 +26,7 @@ class ImageType extends AbstractType {
        /**
         * {@inheritdoc}
         */
-       public function buildForm(FormBuilderInterface $form, array $options): FormBuilderInterface {
+       public function buildForm(FormBuilderInterface $form, array $options): void {
                //With location
                if ($options['location']) {
                        $form->add('location', HiddenType::class, ['required' => true]);
@@ -40,7 +40,7 @@ class ImageType extends AbstractType {
                //With image
                if ($options['image']) {
                        //With image
-                       $form->add('image', FileType::class, ['attr' => ['placeholder' => 'Your image'], 'constraints' => [new File(['maxSize' => '5M', 'mimeTypes' => ['image/jpeg', 'image/png', 'image/tiff', 'image/webp'], 'mimeTypesMessage' => 'Please upload a valid Image document'])]/*, 'mapped' => false*/, 'required' => $options['delete'] ? false : true]);
+                       $form->add('image', FileType::class, ['attr' => ['placeholder' => 'Your image'], 'constraints' => [new File(null, '5M', null, ['image/jpeg', 'image/png', 'image/tiff', 'image/webp'], null, null, null, null, 'Please upload a valid Image document')]/*, 'mapped' => false*/, 'required' => $options['delete'] ? false : true]);
                }
 
                //Add submit
@@ -52,9 +52,6 @@ class ImageType extends AbstractType {
                        //TODO: add confirm on click ?
                        $form->add('delete', SubmitType::class, ['label' => 'Delete', 'attr' => ['class' => 'submit']]);
                }
-
-               //Return form builder
-               return $form;
        }
 
        /**
index 0072d8bc6a254ffb53cebf3a4fd5570e300f748b..95b499232b2bff95897e2b693d981b6bd110cd05 100644 (file)
@@ -33,13 +33,13 @@ class LocationType extends AbstractType {
        public function buildForm(FormBuilderInterface $builder, array $options): void {
                //Build form
                $builder
-                       ->add('title', TextType::class, ['attr' => ['placeholder' => 'Your title'], 'constraints' => [new NotBlank(['message' => 'Please provide your title'])]])
+                       ->add('title', TextType::class, ['attr' => ['placeholder' => 'Your title'], 'constraints' => [new NotBlank(null, 'Please provide your title')]])
                        ->add('description', TextareaType::class, ['attr' => ['placeholder' => 'Your description', 'cols' => 50, 'rows' => 15], 'required' => false])
-                       ->add('address', TextType::class, ['attr' => ['placeholder' => 'Your address'], 'constraints' => [new NotBlank(['message' => 'Please provide your address'])]])
-                       ->add('zipcode', NumberType::class, ['attr' => ['placeholder' => 'Your zipcode'], 'html5' => true, 'constraints' => [new NotBlank(['message' => 'Please provide your zipcode'])]])
-                       ->add('city', TextType::class, ['attr' => ['placeholder' => 'Your city'], 'constraints' => [new NotBlank(['message' => 'Please provide your city'])]])
-                       ->add('latitude', NumberType::class, ['attr' => ['placeholder' => 'Your latitude', 'step' => 0.000001], 'html5' => true, 'scale' => 6, 'constraints' => [new NotBlank(['message' => 'Please provide your latitude'])]])
-                       ->add('longitude', NumberType::class, ['attr' => ['placeholder' => 'Your longitude', 'step' => 0.000001], 'html5' => true, 'scale' => 6, 'constraints' => [new NotBlank(['message' => 'Please provide your longitude'])]])
+                       ->add('address', TextType::class, ['attr' => ['placeholder' => 'Your address'], 'constraints' => [new NotBlank(null, 'Please provide your address')]])
+                       ->add('zipcode', NumberType::class, ['attr' => ['placeholder' => 'Your zipcode'], 'html5' => true, 'constraints' => [new NotBlank(null, 'Please provide your zipcode')]])
+                       ->add('city', TextType::class, ['attr' => ['placeholder' => 'Your city'], 'constraints' => [new NotBlank(null, 'Please provide your city')]])
+                       ->add('latitude', NumberType::class, ['attr' => ['placeholder' => 'Your latitude', 'step' => 0.000001], 'html5' => true, 'scale' => 6, 'constraints' => [new NotBlank(null, 'Please provide your latitude')]])
+                       ->add('longitude', NumberType::class, ['attr' => ['placeholder' => 'Your longitude', 'step' => 0.000001], 'html5' => true, 'scale' => 6, 'constraints' => [new NotBlank(null, 'Please provide your longitude')]])
                        ->add('indoor', CheckboxType::class, ['attr' => ['placeholder' => 'Your indoor'], 'required' => false])
                        ->add('hotspot', CheckboxType::class, ['attr' => ['placeholder' => 'Your hotspot'], 'required' => false])
                        ->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]);
index d6f1ba3095d841abea876e9927a2526c23964936..f7c0756bceca0040d235e9cb5007aa0bdaf58192 100644 (file)
@@ -55,19 +55,19 @@ class SessionType extends AbstractType {
                        if (!empty($options['admin'])) {
                                $builder
                                        //Add dance field
-                                       ->add('dance', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Dance', 'choices' => $options['dance_choices'], 'preferred_choices' => $options['dance_favorites'], 'attr' => ['placeholder' => 'Your dance'], 'choice_translation_domain' => true, 'constraints' => [new NotBlank(['message' => 'Please provide your dance'])], 'data' => $options['dance_default']])
+                                       ->add('dance', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Dance', 'choices' => $options['dance_choices'], 'preferred_choices' => $options['dance_favorites'], 'attr' => ['placeholder' => 'Your dance'], 'choice_translation_domain' => true, 'constraints' => [new NotBlank(null, 'Please provide your dance')], 'data' => $options['dance_default']])
 
                                        //Add slot field
-                                       ->add('slot', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Slot', 'attr' => ['placeholder' => 'Your slot'], 'constraints' => [new NotBlank(['message' => 'Please provide your slot'])], 'choice_translation_domain' => true, 'data' => $options['slot_default']])
+                                       ->add('slot', EntityType::class, ['class' => 'Rapsys\AirBundle\Entity\Slot', 'attr' => ['placeholder' => 'Your slot'], 'constraints' => [new NotBlank(null, 'Please provide your slot')], 'choice_translation_domain' => true, 'data' => $options['slot_default']])
                                        //Add date field
-                                       ->add('date', DateType::class, ['attr' => ['placeholder' => 'Your date', 'class' => 'date'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'format' => 'yyyy-MM-dd', 'data' => $options['date'], 'constraints' => [new NotBlank(['message' => 'Please provide your date']), new Type(['type' => \DateTime::class, 'message' => 'Your date doesn\'t seems to be valid'])]]);
+                                       ->add('date', DateType::class, ['attr' => ['placeholder' => 'Your date', 'class' => 'date'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'format' => 'yyyy-MM-dd', 'data' => $options['date'], 'constraints' => [new NotBlank(null, 'Please provide your date'), new Type(['type' => \DateTime::class, 'message' => 'Your date doesn\'t seems to be valid'])]]);
                        }
 
                        $builder
                                //TODO: avertissement + minimum et maximum ???
-                               ->add('begin', TimeType::class, ['attr' => ['placeholder' => 'Your begin', 'class' => 'time'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'data' => $options['begin'], 'constraints' => [new NotBlank(['message' => 'Please provide your begin']), new Type(['type' => \DateTime::class, 'message' => 'Your begin doesn\'t seems to be valid'])]])
+                               ->add('begin', TimeType::class, ['attr' => ['placeholder' => 'Your begin', 'class' => 'time'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'data' => $options['begin'], 'constraints' => [new NotBlank(null, 'Please provide your begin'), new Type(['type' => \DateTime::class, 'message' => 'Your begin doesn\'t seems to be valid'])]])
                                //TODO: avertissement + minimum et maximum ???
-                               ->add('length', TimeType::class, ['attr' => ['placeholder' => 'Your length', 'class' => 'time'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'data' => $options['length'], 'constraints' => [new NotBlank(['message' => 'Please provide your length']), new Type(['type' => \DateTime::class, 'message' => 'Your length doesn\'t seems to be valid'])]])
+                               ->add('length', TimeType::class, ['attr' => ['placeholder' => 'Your length', 'class' => 'time'], 'html5' => true, 'input' => 'datetime', 'widget' => 'single_text', 'data' => $options['length'], 'constraints' => [new NotBlank(null, 'Please provide your length'), new Type(['type' => \DateTime::class, 'message' => 'Your length doesn\'t seems to be valid'])]])
                                ->add('modify', SubmitType::class, ['label' => 'Modify', 'attr' => ['class' => 'submit']]);
                }
 
@@ -82,7 +82,7 @@ class SessionType extends AbstractType {
                        $locations = $this->doctrine->getRepository(Location::class)->findComplementBySessionId($options['session']);
                        $builder
                                //TODO: class senior en orange ???
-                               ->add('location', ChoiceType::class, ['attr' => ['placeholder' => 'Your location'], 'constraints' => [new NotBlank(['message' => 'Please provide your location'])], 'choices' => $locations, 'choice_translation_domain' => true])
+                               ->add('location', ChoiceType::class, ['attr' => ['placeholder' => 'Your location'], 'constraints' => [new NotBlank(null, 'Please provide your location')], 'choices' => $locations, 'choice_translation_domain' => true])
                                ->add('move', SubmitType::class, ['label' => 'Move', 'attr' => ['class' => 'submit']]);
                }
 
@@ -93,7 +93,7 @@ class SessionType extends AbstractType {
                        //Add admin fields
                        $builder
                                //TODO: class admin en rouge ???
-                               ->add('user', ChoiceType::class, ['attr' => ['placeholder' => 'Your user'], 'constraints' => [new NotBlank(['message' => 'Please provide your user'])], 'choices' => $users, 'data' => $options['user'], 'choice_translation_domain' => false])
+                               ->add('user', ChoiceType::class, ['attr' => ['placeholder' => 'Your user'], 'constraints' => [new NotBlank(null, 'Please provide your user')], 'choices' => $users, 'data' => $options['user'], 'choice_translation_domain' => false])
                                ->add('lock', SubmitType::class, ['label' => 'Lock', 'attr' => ['class' => 'submit']]);
 
                        //Is admin and locked === null
index 8f81b408dc80f3c3ceebefad820b9dbadcbfff89..004499aa838631c1f76f72a240b4eefbd4e040cf 100644 (file)
@@ -21,7 +21,7 @@ class SnippetType extends AbstractType {
        /**
         * {@inheritdoc}
         */
-       public function buildForm(FormBuilderInterface $form, array $options): FormBuilderInterface {
+       public function buildForm(FormBuilderInterface $form, array $options): void {
                //Start build form
                $form
                        //Add locale, location and user hidden fields
@@ -76,9 +76,6 @@ class SnippetType extends AbstractType {
 
                //Add submit
                $form->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]);
-
-               //Return form builder
-               return $form;
        }
 
        /**