src/Form/Login/RequestAccessType.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Form\Login;
  3. use App\Entity\Country;
  4. use App\Entity\CustomerAccount;
  5. use App\Entity\RequestAccess;
  6. use App\Repository\CountryRepository;
  7. use App\Repository\CustomerAccountRepository;
  8. //use Captcha\Bundle\CaptchaBundle\Form\Type\CaptchaType;
  9. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  10. use Symfony\Component\Form\AbstractType;
  11. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  12. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  13. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  14. use Symfony\Component\Form\Extension\Core\Type\TextType;
  15. use Symfony\Component\Form\FormBuilderInterface;
  16. use Symfony\Component\OptionsResolver\OptionsResolver;
  17. class RequestAccessType extends AbstractType
  18. {
  19.     public function buildForm(FormBuilderInterface $builder, array $options)
  20.     {
  21.         $builder
  22.             ->add('customerAccountName')
  23.             ->add('contactFirstName')
  24.             ->add('contactLastName')
  25.             ->add('addressLine1'TextType::class, [
  26.                 'label' => "Address",
  27.                 'attr' => ['autocomplete' => 'disabled'],
  28.                 'required' => true
  29.             ])
  30.             ->add('addressLine2'TextType::class, [
  31.                 'label'=>'Unit/Suite/Apartment',
  32.                 'attr' => ['autocomplete' => 'disabled'],
  33.                 'required' => false
  34.             ])
  35.             ->add('phone')
  36.             ->add('website')
  37.             ->add('email'EmailType::class)
  38.             ->add('IATANumber')
  39.             ->add('customerAccount'EntityType::class, array(
  40.                 'label' => 'Host / Agency Group:',
  41.                 'required' => $options['doFilterByCustomerAccount']?true:false,
  42.                 'class' => CustomerAccount::class,
  43.                 'placeholder' => $options['doFilterByCustomerAccount']?false:'Please choose',
  44.                 'query_builder' => function (CustomerAccountRepository $customerAccountRepo) use ($options) {
  45.                     return $customerAccountRepo->findCustomerAccountsForRequestAccess($options['doFilterByCustomerAccount']);
  46.                 },
  47.                 'empty_data' => null
  48.             ))
  49.             ->add('phoneCountryCode'EntityType::class, array(
  50.                 'label' => "Phone Code",
  51.                 'class' => Country::class,
  52.                 'query_builder' => function (CountryRepository $countryRepo) {
  53.                     return $countryRepo->getUniqueCountryCodeQB();
  54.                 },
  55.                 'placeholder' => 'Choose One',
  56.                 'choice_label' => 'phoneCode'
  57.             ))
  58.             ->add('language')
  59.             ->add('ownershipLink',HiddenType::class)
  60. //            ->add('captchaCode', CaptchaType::class, array(
  61. //                'captchaConfig' => 'ExampleCaptcha'
  62. //            ))
  63.         ;
  64.     }
  65.     public function configureOptions(OptionsResolver $resolver)
  66.     {
  67.         $resolver->setDefaults([
  68.             'data_class' => RequestAccess::class,
  69.             'allow_extra_fields' => true,
  70.             'doFilterByCustomerAccount' => false
  71.         ]);
  72.     }
  73. }