]> Raphaƫl G. Git Repositories - airbundle/blob - Form/CalendarType.php
Add defaults
[airbundle] / Form / CalendarType.php
1 <?php
2
3 namespace Rapsys\AirBundle\Form;
4
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;
11
12 class CalendarType extends AbstractType {
13 /**
14 * {@inheritdoc}
15 */
16 public function buildForm(FormBuilderInterface $builder, array $options) {
17 return $builder
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']]);
26 }
27
28 /**
29 * {@inheritdoc}
30 */
31 public function configureOptions(OptionsResolver $resolver) {
32 $resolver->setDefaults(['error_bubbling' => true]);
33 }
34
35 /**
36 * {@inheritdoc}
37 */
38 public function getName() {
39 return 'calendar_form';
40 }
41 }