<?php
namespace App\Form;
// Voir https://symfony.com/doc/current/reference/forms/types.html
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\BirthdayType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Translation\TranslatorInterface;
class ContactFormType extends AbstractType
{
/**
* @inheritDoc
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$nbannees = \Pimcore\Model\WebsiteSetting::getByName('nbannees', null);
$builder
->add('lastname', TextType::class, [
'label' => 'Nom',
'required' => true,
'attr' => [
'class' => 'uk-input'
]
])
->add('firstname', TextType::class, [
'label' => 'Prénom',
'required' => true,
'attr' => [
'class' => 'uk-input'
]
])
->add('email', TextType::class, [
'label' => 'Email',
'required' => true,
'attr' => [
'class' => 'uk-input'
]
])
->add('phone', TextType::class, [
'label' => 'Téléphone',
'required' => true,
'attr' => [
'class' => 'uk-input'
]
])
->add('message', TextareaType::class, [
'label' => 'Commentaire',
'required' => true,
'attr' => [
'class' => 'uk-textarea',
]
])
->add('birthday', BirthdayType::class, [
'label' => 'Date de naissance',
'required' => true,
'years' => range(date('Y') -$nbannees->getData(), date('Y')),
'attr' => ['class' => 'apk-birthday-date-container'],
'required' => true,
])
->add('sang', ChoiceType::class, [
'label' => 'Déjà donné du sang ?',
'expanded' => true,
'multiple' => false,
'choices' => [
'oui' => 'oui',
'non' => 'non',
],
'required' => true,
])
->add('plasma', ChoiceType::class, [
'label' => 'Déjà donné du plasma ?',
'expanded' => true,
'multiple' => false,
'choices' => [
'oui' => 'oui',
'non' => 'non',
],
'required' => true,
])
->add('gdpr', CheckboxType::class, [
'label' => false,
'required' => true,
'attr' => ['class' => 'uk-checkbox'],
])
->add('recaptcha', HiddenType::class, [
'attr' => [
'class' => 'gs-recaptcha'
],
'required' => false
])
->add('submit', SubmitType::class, [
'label' => 'Envoyer',
'attr' => [
'class' => 'uk-button uk-button-large'
]
]);
}
/**
* @inheritDoc
*/
public function configureOptions(OptionsResolver $resolver)
{
}
}