]> Raphaël G. Git Repositories - airbundle/blob - Form/CalendarType.php
Reorder constructor arguments
[airbundle] / Form / CalendarType.php
1 <?php declare(strict_types=1);
2
3 /*
4 * This file is part of the Rapsys AirBundle package.
5 *
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Rapsys\AirBundle\Form;
13
14 use Symfony\Component\Form\AbstractType;
15 use Symfony\Component\Form\FormBuilderInterface;
16 use Symfony\Component\OptionsResolver\OptionsResolver;
17 use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
18 use Symfony\Component\Form\Extension\Core\Type\SubmitType;
19
20 class CalendarType extends AbstractType {
21 /**
22 * {@inheritdoc}
23 */
24 public function buildForm(FormBuilderInterface $builder, array $options): void {
25 //Build form
26 $builder
27 ->add('calendar', ChoiceType::class, ['attr' => ['placeholder' => 'Your calendar'], 'choice_translation_domain' => false, 'expanded' => true, 'multiple' => true, 'choices' => $options['calendar_choices']/*, 'data' => $options['calendar_default']*/, 'choice_attr' => ['class' => 'row']])
28 ->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']])
29 ->add('refresh', SubmitType::class, ['label' => 'Refresh', 'attr' => ['class' => 'submit']])
30 ->add('add', SubmitType::class, ['label' => 'Add', 'attr' => ['class' => 'submit']])
31 ->add('delete', SubmitType::class, ['label' => 'Delete', 'attr' => ['class' => 'submit']])
32 ->add('unlink', SubmitType::class, ['label' => 'Unlink', 'attr' => ['class' => 'submit']]);
33 }
34
35 /**
36 * {@inheritdoc}
37 */
38 public function configureOptions(OptionsResolver $resolver): void {
39 //Set defaults
40 $resolver->setDefaults(['error_bubbling' => true, 'calendar_choices' => [], /*'calendar_default' => ['primary']*/]);
41
42 //Add calendar choices
43 $resolver->setAllowedTypes('calendar_choices', 'array');
44
45 //Add calendar default
46 #$resolver->setAllowedTypes('calendar_default', 'integer');
47 }
48
49 /**
50 * {@inheritdoc}
51 */
52 public function getName(): string {
53 return 'calendar_form';
54 }
55 }