src/Form/Web/VIPaccountType.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Form\Web;
  3. use App\Entity\VIPaccount;
  4. use App\Enum\ClientEnum;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  7. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  8. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  9. use Symfony\Component\Form\Extension\Core\Type\TextType;
  10. use Symfony\Component\Form\FormBuilderInterface;
  11. use Symfony\Component\OptionsResolver\OptionsResolver;
  12. class VIPaccountType extends AbstractType
  13. {
  14. public function buildForm(FormBuilderInterface $builder, array $options): void
  15. {
  16. $builder
  17. ->add('firstName', TextType::class, [
  18. 'label' => 'cart.address.firstName'
  19. ])
  20. ->add('lastName', TextType::class, [
  21. 'label' => 'cart.address.lastName'
  22. ])
  23. ->add('email', EmailType::class, [
  24. 'label' => 'cart.address.email',
  25. 'required' => false
  26. ])
  27. ->add('language', ChoiceType::class, [
  28. 'label' => 'address.language',
  29. 'choices' => array_flip(ClientEnum::COUNTRY),
  30. 'translation_domain' => 'admin',
  31. 'expanded' => !$options['admin']
  32. ]);
  33. if ($options['admin']) {
  34. $builder->add('cardNumber', TextType::class, [
  35. 'label' => 'Číslo karty'
  36. ]);
  37. }else{
  38. $builder->add('oop', CheckboxType::class, [
  39. 'label' => 'vip.oop',
  40. 'mapped' => false,
  41. 'required' => true,
  42. 'translation_domain' => 'web',
  43. 'label_html' => true
  44. ]);
  45. }
  46. }
  47. public function configureOptions(OptionsResolver $resolver): void
  48. {
  49. $resolver->setDefaults([
  50. 'data_class' => VIPaccount::class,
  51. 'admin' => false
  52. ]);
  53. }
  54. }