]> Raphaël G. Git Repositories - airbundle/commitdiff
Add calendar form
authorRaphaël Gertz <git@rapsys.eu>
Wed, 7 Jul 2021 15:22:38 +0000 (17:22 +0200)
committerRaphaël Gertz <git@rapsys.eu>
Wed, 7 Jul 2021 15:22:38 +0000 (17:22 +0200)
Form/CalendarType.php [new file with mode: 0644]

diff --git a/Form/CalendarType.php b/Form/CalendarType.php
new file mode 100644 (file)
index 0000000..be5fcab
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+
+namespace Rapsys\AirBundle\Form;
+
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+use Symfony\Component\Form\Extension\Core\Type\TextType;
+use Symfony\Component\Form\Extension\Core\Type\SubmitType;
+use Symfony\Component\Validator\Constraints\NotBlank;
+
+class CalendarType extends AbstractType {
+       /**
+        * {@inheritdoc}
+        */
+       public function buildForm(FormBuilderInterface $builder, array $options) {
+               return $builder
+                       ->add('calendar', TextType::class, ['label' => 'Calendar id', 'attr' => ['placeholder' => 'Your calendar id'], 'constraints' => [new NotBlank(['message' => 'Please provide your calendar id'])]])
+                       //TODO: validate prefix against [a-v0-9]{5,}
+                       //XXX: see https://developers.google.com/calendar/api/v3/reference/events/insert#id
+                       ->add('prefix', TextType::class, ['label' => 'Prefix', 'attr' => ['placeholder' => 'Your prefix'], 'constraints' => [new NotBlank(['message' => 'Please provide your prefix'])]])
+                       ->add('project', TextType::class, ['label' => 'Project id', 'attr' => ['placeholder' => 'Your project id'], 'required' => false])
+                       ->add('client', TextType::class, ['label' => 'Client id', 'attr' => ['placeholder' => 'Your client id'], 'required' => false])
+                       ->add('secret', TextType::class, ['label' => 'Client secret', 'attr' => ['placeholder' => 'Your client secret'], 'required' => false])
+                       ->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]);
+       }
+
+       /**
+        * {@inheritdoc}
+        */
+       public function configureOptions(OptionsResolver $resolver) {
+               $resolver->setDefaults(['error_bubbling' => true]);
+       }
+
+       /**
+        * {@inheritdoc}
+        */
+       public function getName() {
+               return 'calendar_form';
+       }
+}