3 namespace Rapsys\AirBundle\Form
;
5 use Symfony\Component\Form\AbstractType
;
6 use Symfony\Component\Form\FormBuilderInterface
;
7 use Symfony\Component\OptionsResolver\OptionsResolver
;
8 use Symfony\Component\Form\Extension\Core\Type\TextType
;
9 use Symfony\Component\Form\Extension\Core\Type\SubmitType
;
10 use Symfony\Component\Validator\Constraints\NotBlank
;
12 class CalendarType
extends AbstractType
{
16 public function buildForm(FormBuilderInterface
$builder, array $options) {
18 ->add('calendar', TextType
::class, ['label' => 'Calendar id', 'attr' => ['placeholder' => 'Your calendar id'], 'constraints' => [new NotBlank(['message' => 'Please provide your calendar id'])]])
19 //TODO: validate prefix against [a-v0-9]{5,}
20 //XXX: see https://developers.google.com/calendar/api/v3/reference/events/insert#id
21 ->add('prefix', TextType
::class, ['label' => 'Prefix', 'attr' => ['placeholder' => 'Your prefix'], 'constraints' => [new NotBlank(['message' => 'Please provide your prefix'])]])
22 ->add('project', TextType
::class, ['label' => 'Project id', 'attr' => ['placeholder' => 'Your project id'], 'required' => false])
23 ->add('client', TextType
::class, ['label' => 'Client id', 'attr' => ['placeholder' => 'Your client id'], 'required' => false])
24 ->add('secret', TextType
::class, ['label' => 'Client secret', 'attr' => ['placeholder' => 'Your client secret'], 'required' => false])
25 ->add('submit', SubmitType
::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]);
31 public function configureOptions(OptionsResolver
$resolver) {
32 $resolver->setDefaults(['error_bubbling' => true]);
38 public function getName() {
39 return 'calendar_form';