]> Raphaël G. Git Repositories - airbundle/blobdiff - Form/RegisterType.php
Remove disputed form
[airbundle] / Form / RegisterType.php
index 68c9309a0e4f72ad97c2df28755bea2ff5766909..06e5f36d0d0fecf870f4e79eac34f1b53f4e7c8b 100644 (file)
@@ -1,7 +1,7 @@
 <?php declare(strict_types=1);
 
 /*
- * This file is part of the Rapsys PackBundle package.
+ * This file is part of the Rapsys AirBundle package.
  *
  * (c) Raphaël Gertz <symfony@rapsys.eu>
  *
 
 namespace Rapsys\AirBundle\Form;
 
-use Symfony\Component\Form\Extension\Core\Type\TextType;
+use Symfony\Bridge\Doctrine\Form\Type\EntityType;
 use Symfony\Component\Form\Extension\Core\Type\TelType;
-use Symfony\Component\Form\Extension\Core\Type\UrlType;
+use Symfony\Component\Form\Extension\Core\Type\TextType;
 use Symfony\Component\Form\FormBuilderInterface;
 use Symfony\Component\OptionsResolver\OptionsResolver;
-use Symfony\Component\Validator\Constraints\NotBlank;
 
-class RegisterType extends \Rapsys\UserBundle\Form\RegisterType {
+use Rapsys\AirBundle\Entity\Country;
+
+use Rapsys\UserBundle\Form\RegisterType as BaseRegisterType;
+
+class RegisterType extends BaseRegisterType {
        /**
         * {@inheritdoc}
         */
@@ -26,14 +29,15 @@ class RegisterType extends \Rapsys\UserBundle\Form\RegisterType {
                //Call parent build form
                $form = parent::buildForm($builder, $options);
 
-               //Add extra donate field
-               if (!empty($options['donate'])) {
-                       $form->add('donate', UrlType::class, ['attr' => ['placeholder' => 'Your donate'], 'required' => false]);
+               //Add extra city field
+               if (!empty($options['city'])) {
+                       $form->add('city', TextType::class, ['attr' => ['placeholder' => 'Your city'], 'required' => false]);
                }
 
-               //Add extra link field
-               if (!empty($options['link'])) {
-                       $form->add('link', UrlType::class, ['attr' => ['placeholder' => 'Your link'], 'required' => false]);
+               //Add extra country field
+               if (!empty($options['country'])) {
+                       //Add country field
+                       $form->add('country', EntityType::class, ['class' => $options['country_class'], 'choice_label' => 'title'/*, 'choices' => $options['location_choices']*/, 'preferred_choices' => $options['country_favorites'], 'attr' => ['placeholder' => 'Your country'], 'choice_translation_domain' => false, 'required' => true, 'data' => $options['country_default']]);
                }
 
                //Add extra phone field
@@ -41,9 +45,14 @@ class RegisterType extends \Rapsys\UserBundle\Form\RegisterType {
                        $form->add('phone', TelType::class, ['attr' => ['placeholder' => 'Your phone'], 'required' => false]);
                }
 
-               //Add extra profile field
-               if (!empty($options['profile'])) {
-                       $form->add('profile', UrlType::class, ['attr' => ['placeholder' => 'Your profile'], 'required' => false]);
+               //Add extra pseudonym field
+               if (!empty($options['pseudonym'])) {
+                       $form->add('pseudonym', TextType::class, ['attr' => ['placeholder' => 'Your pseudonym'], 'required' => false]);
+               }
+
+               //Add extra zipcode field
+               if (!empty($options['zipcode'])) {
+                       $form->add('zipcode', TextType::class, ['attr' => ['placeholder' => 'Your zipcode'], 'required' => false]);
                }
 
                //Return form
@@ -58,19 +67,31 @@ class RegisterType extends \Rapsys\UserBundle\Form\RegisterType {
                parent::configureOptions($resolver);
 
                //Set defaults
-               $resolver->setDefaults(['donate' => true, 'link' => true, 'phone' => true, 'profile' => true]);
+               $resolver->setDefaults(['city' => true, 'country' => true, 'country_class' => 'RapsysAirBundle:Country', 'country_default' => null, 'country_favorites' => [], 'phone' => true, 'pseudonym' => true, 'zipcode' => true]);
+
+               //Add extra city option
+               $resolver->setAllowedTypes('city', 'boolean');
+
+               //Add extra country option
+               $resolver->setAllowedTypes('country', 'boolean');
 
-               //Add extra donate option
-               $resolver->setAllowedTypes('donate', 'boolean');
+               //Add country class
+               $resolver->setAllowedTypes('country_class', 'string');
 
-               //Add extra link option
-               $resolver->setAllowedTypes('link', 'boolean');
+               //Add country default
+               $resolver->setAllowedTypes('country_default', [Country::class, 'null']);
+
+               //Add country favorites
+               $resolver->setAllowedTypes('country_favorites', 'array');
 
                //Add extra phone option
                $resolver->setAllowedTypes('phone', 'boolean');
 
-               //Add extra profile option
-               $resolver->setAllowedTypes('profile', 'boolean');
+               //Add extra pseudonym option
+               $resolver->setAllowedTypes('pseudonym', 'boolean');
+
+               //Add extra zipcode option
+               $resolver->setAllowedTypes('zipcode', 'boolean');
        }