]> Raphaël G. Git Repositories - airbundle/blob - Form/LocationType.php
Register google client service and alias
[airbundle] / Form / LocationType.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\Extension\Core\Type\CheckboxType;
16 use Symfony\Component\Form\Extension\Core\Type\NumberType;
17 use Symfony\Component\Form\Extension\Core\Type\SubmitType;
18 use Symfony\Component\Form\Extension\Core\Type\TextareaType;
19 use Symfony\Component\Form\Extension\Core\Type\TextType;
20 use Symfony\Component\Form\FormBuilderInterface;
21 use Symfony\Component\OptionsResolver\OptionsResolver;
22 use Symfony\Component\Validator\Constraints\NotBlank;
23
24 use Rapsys\AirBundle\Entity\Location;
25
26 /**
27 * {@inheritdoc}
28 */
29 class LocationType extends AbstractType {
30 /**
31 * {@inheritdoc}
32 */
33 public function buildForm(FormBuilderInterface $builder, array $options): void {
34 //Build form
35 $builder
36 ->add('title', TextType::class, ['attr' => ['placeholder' => 'Your title'], 'constraints' => [new NotBlank(['message' => 'Please provide your title'])]])
37 ->add('description', TextareaType::class, ['attr' => ['placeholder' => 'Your description', 'cols' => 50, 'rows' => 15], 'required' => false])
38 ->add('address', TextType::class, ['attr' => ['placeholder' => 'Your address'], 'constraints' => [new NotBlank(['message' => 'Please provide your address'])]])
39 ->add('zipcode', NumberType::class, ['attr' => ['placeholder' => 'Your zipcode'], 'html5' => true, 'constraints' => [new NotBlank(['message' => 'Please provide your zipcode'])]])
40 ->add('city', TextType::class, ['attr' => ['placeholder' => 'Your city'], 'constraints' => [new NotBlank(['message' => 'Please provide your city'])]])
41 ->add('latitude', NumberType::class, ['attr' => ['placeholder' => 'Your latitude', 'step' => 0.000001], 'html5' => true, 'scale' => 6, 'constraints' => [new NotBlank(['message' => 'Please provide your latitude'])]])
42 ->add('longitude', NumberType::class, ['attr' => ['placeholder' => 'Your longitude', 'step' => 0.000001], 'html5' => true, 'scale' => 6, 'constraints' => [new NotBlank(['message' => 'Please provide your longitude'])]])
43 ->add('indoor', CheckboxType::class, ['attr' => ['placeholder' => 'Your indoor'], 'required' => false])
44 ->add('hotspot', CheckboxType::class, ['attr' => ['placeholder' => 'Your hotspot'], 'required' => false])
45 ->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]);
46 }
47
48 /**
49 * {@inheritdoc}
50 */
51 public function configureOptions(OptionsResolver $resolver): void {
52 $resolver->setDefaults(['data_class' => Location::class, 'error_bubbling' => true]);
53 }
54 }