<?php
namespace App\Form\Login;
use App\Entity\Country;
use App\Entity\CustomerAccount;
use App\Entity\RequestAccess;
use App\Repository\CountryRepository;
use App\Repository\CustomerAccountRepository;
//use Captcha\Bundle\CaptchaBundle\Form\Type\CaptchaType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class RequestAccessType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('customerAccountName')
->add('contactFirstName')
->add('contactLastName')
->add('addressLine1', TextType::class, [
'label' => "Address",
'attr' => ['autocomplete' => 'disabled'],
'required' => true
])
->add('addressLine2', TextType::class, [
'label'=>'Unit/Suite/Apartment',
'attr' => ['autocomplete' => 'disabled'],
'required' => false
])
->add('phone')
->add('website')
->add('email', EmailType::class)
->add('IATANumber')
->add('customerAccount', EntityType::class, array(
'label' => 'Host / Agency Group:',
'required' => $options['doFilterByCustomerAccount']?true:false,
'class' => CustomerAccount::class,
'placeholder' => $options['doFilterByCustomerAccount']?false:'Please choose',
'query_builder' => function (CustomerAccountRepository $customerAccountRepo) use ($options) {
return $customerAccountRepo->findCustomerAccountsForRequestAccess($options['doFilterByCustomerAccount']);
},
'empty_data' => null
))
->add('phoneCountryCode', EntityType::class, array(
'label' => "Phone Code",
'class' => Country::class,
'query_builder' => function (CountryRepository $countryRepo) {
return $countryRepo->getUniqueCountryCodeQB();
},
'placeholder' => 'Choose One',
'choice_label' => 'phoneCode'
))
->add('language')
->add('ownershipLink',HiddenType::class)
// ->add('captchaCode', CaptchaType::class, array(
// 'captchaConfig' => 'ExampleCaptcha'
// ))
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => RequestAccess::class,
'allow_extra_fields' => true,
'doFilterByCustomerAccount' => false
]);
}
}