<?php
namespace App\Form\Web;
use App\Entity\VIPaccount;
use App\Enum\ClientEnum;
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\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class VIPaccountType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('firstName', TextType::class, [
'label' => 'cart.address.firstName'
])
->add('lastName', TextType::class, [
'label' => 'cart.address.lastName'
])
->add('email', EmailType::class, [
'label' => 'cart.address.email',
'required' => false
])
->add('language', ChoiceType::class, [
'label' => 'address.language',
'choices' => array_flip(ClientEnum::COUNTRY),
'translation_domain' => 'admin',
'expanded' => !$options['admin']
]);
if ($options['admin']) {
$builder->add('cardNumber', TextType::class, [
'label' => 'Číslo karty'
]);
}else{
$builder->add('oop', CheckboxType::class, [
'label' => 'vip.oop',
'mapped' => false,
'required' => true,
'translation_domain' => 'web',
'label_html' => true
]);
}
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => VIPaccount::class,
'admin' => false
]);
}
}