<?php
namespace App\Form;
use App\Entity\Contact;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Validator\Constraints\NotBlank;
class ContactType extends AbstractType
{
private $router;
public function __construct(UrlGeneratorInterface $router)
{
$this->router = $router;
}
public function getBlockPrefix()
{
return "prvdfq";
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
if (!$options["noSubject"]) {
$builder
->add('sknqst', ChoiceType::class, array(
"property_path" => "subject",
'choices' => [
"Information Request" => "Information Request",
"Quote Request" => "Quote Request",
"Demo Request" => "Demo Request"
],
"placeholder" => " ",
"attr" => array(
"class" => "selectpicker",
"data-live-search" => "true",
),
"label_attr" => array(
"class" => "",
),
'multiple' => false,
'expanded' => false,
"label" => "contact_type.subject.placeholder",
// "attr" => ["placeholder" => "contact_type.subject.placeholder"],
'required' => true
));
}
$builder
->add('xcktqe', null, [
"property_path" => "lastname",
"label" => "contact_type.lastname.placeholder",
"constraints" => [new NotBlank()]
])
->add('tqraik', null, [
"property_path" => "firstname",
"label" => "contact_type.firstname.placeholder",
// "attr" => ["placeholder" => "contact_type.firstname.placeholder"]
])
->add('ffoqxj', null, [
"property_path" => "email",
"constraints" => [new NotBlank()],
"label" => "contact_type.email.placeholder",
// "attr" => ["placeholder" => "contact_type.email.placeholder"],
])
->add('mdvzwo', null, [
"property_path" => "phoneNumber",
"label" => "contact_type.phoneNumber.placeholder",
// "attr" => ["placeholder" => "contact_type.phoneNumber.placeholder"],
])
->add('kaxlkw', null, [
"property_path" => "society",
"constraints" => [new NotBlank()],
"label" => "contact_type.society.placeholder",
// "attr" => ["placeholder" => "contact_type.society.placeholder"],
])
->add('ahuowd', null, [
"property_path" => "country",
"constraints" => [new NotBlank()],
"label" => "contact_type.country.placeholder",
// "attr" => ["placeholder" => "contact_type.country.placeholder"],
])
->add('dumenr', TextareaType::class, [
"property_path" => "message",
"constraints" => [new NotBlank()],
"label" => "contact_type.message.placeholder",
"attr" => [
"rows" => 5
]
// "attr" => ["placeholder" => "contact_type.message.placeholder"],
])
->add('middlename', null, [ // Hack to prevent bots from sending the form. The field is invisible in front and if it is filled, the contact silently fail
"label" => "Middle name*",
"mapped" => false,
])
->add("pncooa", CheckboxType::class, [
"property_path" => "condition",
"mapped" => false,
"required" => true,
"attr" => ["rows" => 5],
"label_attr" => [
"class" => "fw-400 checkbox-custom"
],
'label' => 'contact_type.condition_label',
'label_translation_parameters' => [
'%url%' => $this->router->generate('front_privacy_policy'),
],
"label_html" => true,
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Contact::class,
'noSubject' => false,
]);
}
}