<?php
namespace App\Form;
use Doctrine\DBAL\Types\TextType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\RadioType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
class MainFormType extends AbstractType
{
public function getDefaultOptions(array $options)
{
return array(
'csrf_protection' => false,
// Rest of options omitted
);
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$datas = $options['data'];
$local = $datas['local'];
$continuBtnText = null;
$firstCustomAwnser = null;
$secondCustomAwnser = null;
$thirdCustomAwnser = null;
if ($local) {
switch ($local) {
case 'fr':
$continuBtnText = "Continuer";
break;
case 'pt':
case 'es':
$continuBtnText = "Continuar";
break;
}
}
if ($datas['selectedQuestion'] != null) {
$choice1 = $datas['selectedQuestion']->getFirstcustomawnser() ?? 'Pas du tout d\'accord';
$choice2 = $datas['selectedQuestion']->getSecondcustomawnser() ?? 'Plutôt d\'accord';
$choice3 = $datas['selectedQuestion']->getThirdcustomawnser() ?? 'Tout à fait d\'accord';
}
$builder
->add('expertise', ChoiceType::class, [
'choices' => [
$choice1 => 1,
$choice2 => 2,
$choice3 => 3
],
'expanded' => true,
'multiple' => false,
'allow_extra_fields' => true,
])
->add($continuBtnText, SubmitType::class, [
'attr' => [
'class' => 'form-btn savebtn js-continue-btn',
'id' => 'js-continue-btn',
]
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'csrf_protection' => false,
]);
}
}