You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 line
2.8KB

  1. <?php
  2. namespace Lc\ShopBundle\Form\Frontend;
  3. use FOS\UserBundle\Form\Type\RegistrationFormType as BaseRegistrationFormType;
  4. use Lc\ShopBundle\Services\UtilsManager;
  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\TextType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. class RegistrationType extends AbstractType
  11. {
  12. protected $utils ;
  13. public function __construct(UtilsManager $utilsManager)
  14. {
  15. $this->utils = $utilsManager->getUtils() ;
  16. $this->merchantUtils = $utilsManager->getMerchantUtils() ;
  17. }
  18. public function getParent()
  19. {
  20. return BaseRegistrationFormType::class;
  21. }
  22. public function buildForm(FormBuilderInterface $builder, array $options)
  23. {
  24. $newsletters = $this->merchantUtils->getMerchantCurrent()->getNewsletters() ;
  25. $builder->remove('username')
  26. ->add('gender', ChoiceType::class, [
  27. 'label' => 'field.default.title',
  28. 'multiple' => false,
  29. 'expanded' => true,
  30. 'choices' => [
  31. 'field.default.madame' => 1,
  32. 'field.default.monsieur' => 0,
  33. ],
  34. 'translation_domain' => 'lcshop',
  35. ])
  36. ->add('firstName', TextType::class, [
  37. 'label' => 'field.default.firstname',
  38. 'translation_domain' => 'lcshop',
  39. ])
  40. ->add('lastName', TextType::class, [
  41. 'label' => 'field.default.lastname',
  42. 'translation_domain' => 'lcshop',
  43. ])
  44. ->add('phone', TextType::class, [
  45. 'label' => 'field.default.phone',
  46. 'translation_domain' => 'lcshop',
  47. ]);
  48. foreach($newsletters as $newsletter) {
  49. $builder->add('newsletter_'.$newsletter->getId(), CheckboxType::class, [
  50. //'label' => 'field.default.subscribeNewsletter',
  51. 'label' => $newsletter->getTitle(),
  52. 'required' => false,
  53. 'mapped' => false,
  54. 'translation_domain' => 'lcshop',
  55. 'help' => $newsletter->getDescription()
  56. ]);
  57. }
  58. // captcha
  59. $this->utils->addCaptchaType($builder);
  60. }
  61. }