]> Raphaël G. Git Repositories - airbundle/blob - Form/LocationType.php
Removed
[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) {
34 return $builder
35 ->add('title', TextType::class, ['attr' => ['placeholder' => 'Your title'], 'constraints' => [new NotBlank(['message' => 'Please provide your title'])]])
36 ->add('description', TextareaType::class, ['attr' => ['placeholder' => 'Your description', 'cols' => 50, 'rows' => 15], 'required' => false])
37 ->add('address', TextType::class, ['attr' => ['placeholder' => 'Your address'], 'constraints' => [new NotBlank(['message' => 'Please provide your address'])]])
38 ->add('zipcode', NumberType::class, ['attr' => ['placeholder' => 'Your zipcode'], 'html5' => true, 'constraints' => [new NotBlank(['message' => 'Please provide your zipcode'])]])
39 ->add('city', TextType::class, ['attr' => ['placeholder' => 'Your city'], 'constraints' => [new NotBlank(['message' => 'Please provide your city'])]])
40 ->add('latitude', NumberType::class, ['attr' => ['placeholder' => 'Your latitude', 'step' => 0.000001], 'html5' => true, 'scale' => 6, 'constraints' => [new NotBlank(['message' => 'Please provide your latitude'])]])
41 ->add('longitude', NumberType::class, ['attr' => ['placeholder' => 'Your longitude', 'step' => 0.000001], 'html5' => true, 'scale' => 6, 'constraints' => [new NotBlank(['message' => 'Please provide your longitude'])]])
42 ->add('indoor', CheckboxType::class, ['attr' => ['placeholder' => 'Your indoor'], 'required' => false])
43 ->add('hotspot', CheckboxType::class, ['attr' => ['placeholder' => 'Your hotspot'], 'required' => false])
44 ->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]);
45 }
46
47 /**
48 * {@inheritdoc}
49 */
50 public function configureOptions(OptionsResolver $resolver) {
51 $resolver->setDefaults(['data_class' => Location::class, 'error_bubbling' => true]);
52 }
53 }