src/SymfonyDev/AppBundle/Form/RegisterType.php line 11

Open in your IDE?
  1. <?php
  2. namespace SymfonyDev\AppBundle\Form;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\FormBuilderInterface;
  5. use Symfony\Component\OptionsResolver\OptionsResolver;
  6. use Symfony\Component\Form\Extension\Core\Type as FT;
  7. use SymfonyDev\AppBundle\Entity\User;
  8. class RegisterType extends AbstractType
  9. {
  10.     /**
  11.      * {@inheritdoc}
  12.      */
  13.     public function buildForm(FormBuilderInterface $builder, array $options)
  14.     {
  15.         $data $options['data'];
  16.         $builder
  17.             ->add('title'FT\ChoiceType::class, array(
  18.                 'required' => true,
  19.                 'expanded' => false,
  20.                 'choices'  => array(
  21.                     User::USER_TITLE_MR => User::USER_TITLE_MR,
  22.                     User::USER_TITLE_MRS => User::USER_TITLE_MRS,
  23.                     User::USER_TITLE_MS => User::USER_TITLE_MS,
  24.                     User::USER_TITLE_MISS => User::USER_TITLE_MISS,
  25.                     User::USER_TITLE_DR => User::USER_TITLE_DR,
  26.                     User::USER_TITLE_MX => User::USER_TITLE_MX
  27.                 )
  28.             ))
  29.             ->add('firstName'null, array('required' => true))
  30.             ->add('lastName'null, array('required' => true))
  31.             ->add('dateOfBirth'null, array('required' => true'widget' => 'single_text''format' => 'dd/MM/yyyy'))
  32.             ->add('email'null, array('required' => true))
  33.             ->add('plainPassword'FT\RepeatedType::class, array(
  34.                 'type' => FT\PasswordType::class,
  35.                 'required' => true,
  36.                 'invalid_message' => 'Password and Confirm Password should be same.',
  37.                 'first_options' => array('label' => 'Password'),
  38.                 'second_options' => array('label' => 'Confirm Password'),
  39.             ))
  40.             ->add('website'null, array('required' => false))
  41.             ->add('workPhone'null, array('required' => true))
  42.             ->add('mobile'null, array('required' => true))
  43.             ->add('isNews'null, array('required' => false'label' => false))
  44.             ->add(
  45.                 'addresses',
  46.                 FT\CollectionType::class,
  47.                 array(
  48.                     'label' => false,
  49.                     'required' => true,
  50.                     'allow_add' => true,
  51.                     'allow_delete' => true,
  52.                     'entry_type' => AddressType::class,
  53.                     'prototype' => true,
  54.                     'error_bubbling' => false,
  55.                     'by_reference' => false
  56.                 )
  57.             )
  58.         ;
  59.         
  60.         if ($options['user_type'] == User::USER_USER_TYPE_PRACTITIONER || $options['user_type'] == User::USER_USER_TYPE_STUDENT) {
  61.             $builder
  62.                 ->add('registration'null, array('required' => true))
  63.                 ->add('association'null, array('required' => true))
  64.             ;
  65.         }
  66.         
  67.         if ($options['user_type'] == User::USER_USER_TYPE_PRACTITIONER || $options['user_type'] == User::USER_USER_TYPE_STUDENT || $options['user_type'] == User::USER_USER_TYPE_USER) {
  68.             $builder
  69.                 ->add('howDidYouFindUs'FT\ChoiceType::class, array(
  70.                     'constraints' => [
  71.                         new \Symfony\Component\Validator\Constraints\NotBlank()
  72.                     ],
  73.                     'label' => false,
  74.                     'required' => true,
  75.                     'expanded' => true,
  76.                     'multiple' => true,
  77.                     'choices'  => array(
  78.                         'Referral from a colleague'=>'Referral from a colleague',
  79.                         'Advertisement'=>'Advertisement',
  80.                         'Internet search'=>'Internet search',
  81.                         'Event'=>'Event',
  82.                         'Webinar'=>'Webinar',
  83.                         'University'=>'University',
  84.                         'Blog'=>'Blog',
  85.                         'Acuneeds'=>'Acuneeds',
  86.                         'San Acupuncture supplies'=>'San Acupuncture supplies',
  87.                         'Social media'=>'Social media'
  88.                     )
  89.                 ))
  90.             ;
  91.         }
  92.     }
  93.     
  94.     /**
  95.      * {@inheritdoc}
  96.      */
  97.     public function configureOptions(OptionsResolver $resolver)
  98.     {
  99.         $resolver->setDefaults(array(
  100.             'data_class' => 'SymfonyDev\AppBundle\Entity\User',
  101.             'user_type' => null,
  102.         ));
  103.     }
  104.     /**
  105.      * {@inheritdoc}
  106.      */
  107.     public function getBlockPrefix()
  108.     {
  109.         return 'symfonydev_appbundle_register';
  110.     }
  111. }