From 3712d1d4d52661bec412059fc56bb68532b8403e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Wed, 24 Feb 2021 01:44:21 +0100 Subject: [PATCH] Add location form type --- Form/LocationType.php | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Form/LocationType.php diff --git a/Form/LocationType.php b/Form/LocationType.php new file mode 100644 index 0000000..53784a9 --- /dev/null +++ b/Form/LocationType.php @@ -0,0 +1,55 @@ +setAttribute('label_prefix', $options['label_prefix']) + ->add('title', TextType::class, ['attr' => ['placeholder' => 'Your title']]) + ->add('short', TextType::class, ['attr' => ['placeholder' => 'Your short']]) + ->add('address', TextType::class, ['attr' => ['placeholder' => 'Your address']]) + ->add('zipcode', NumberType::class, ['attr' => ['placeholder' => 'Your zipcode'], 'html5' => true]) + ->add('city', TextType::class, ['attr' => ['placeholder' => 'Your city']]) + ->add('latitude', NumberType::class, ['attr' => ['placeholder' => 'Your latitude', 'step' => 0.000001], 'html5' => true, 'scale' => 6]) + ->add('longitude', NumberType::class, ['attr' => ['placeholder' => 'Your longitude', 'step' => 0.000001], 'html5' => true, 'scale' => 6]) + ->add('hotspot', CheckboxType::class, ['attr' => ['placeholder' => 'Your hotspot'], 'required' => false]) + ->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]); + } + + /** + * {@inheritdoc} + * + public function buildView(FormView $view, FormInterface $form, array $options) { + #$labelPrefix = $form->getRoot()->hasAttribute('label_prefix') ? $form->getRoot()->getAttribute('label_prefix') : ''; + #$labelPrefix = $form->getConfig()->hasAttribute('label_prefix'); + #$labelPrefix = $form->getConfig()->getAttribute('label_prefix'); + #var_dump($view); + var_dump($view['label']); + exit; + //Prefix label to prevent collision + $view['label'] = $form->getConfig()->getAttribute('label_prefix').$view->getVar('label'); + }*/ + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { + $resolver->setDefaults(['data_class' => Location::class, 'error_bubbling' => true, 'label_prefix' => '']); + } +} -- 2.41.0