<?php
namespace App\Form\Front;
use App\Entity\Accommodation;
use App\Entity\ContactMessage;
use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType;
use EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue as RecaptchaTrue;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Routing\RouterInterface;
class ContactRoomType extends AbstractType
{
private $router;
public function __construct(RouterInterface $router)
{
$this->router = $router;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('recaptcha', EWZRecaptchaType::class, [
'attr' => [
'options' => [
'theme' => 'light',
'type' => 'image',
'size' => 'small'
]
],
'mapped' => false,
'constraints' => array(
new RecaptchaTrue()
)
])
->add('firstname', TextType::class, array('label' => 'label.firstname'))
->add('lastname', TextType::class, array('label' => 'label.lastname'))
->add('email', EmailType::class, array('label' => 'label.email'))
->add('phone', TextType::class, array('label' => 'label.phone'))
->add('nationality', TextType::class, array('label' => 'label.nationality'))
->add('age', NumberType::class, array('label' => 'label.age'))
->add('dateFrom', DateType::class, array(
'label' => 'label.contractDateFrom',
'widget' => 'single_text',
'required' => false,
))
->add('dateTo', DateType::class, array(
'label' => 'label.contractDateTo',
'widget' => 'single_text',
'required' => false,
))
->add('message', TextareaType::class, array('label' => 'label.message'))
->add('optin', CheckboxType::class, array('label' => 'label.acceptOptin', 'required' => true))
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => ContactMessage::class,
'translation_domain' => 'front',
'type' => '',
));
}
}