|
- <?php
-
- namespace Lc\ShopBundle\Form\Frontend;
-
- use FOS\UserBundle\Form\Type\RegistrationFormType as BaseRegistrationFormType;
- use Lc\ShopBundle\Services\UtilsManager;
- 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\TextType;
- use Symfony\Component\Form\FormBuilderInterface;
-
- class RegistrationType extends AbstractType
- {
- protected $utils ;
-
- public function __construct(UtilsManager $utilsManager)
- {
- $this->utils = $utilsManager->getUtils() ;
- $this->merchantUtils = $utilsManager->getMerchantUtils() ;
- }
-
- public function getParent()
- {
- return BaseRegistrationFormType::class;
- }
-
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- $newsletters = $this->merchantUtils->getMerchantCurrent()->getNewsletters() ;
-
- $builder->remove('username')
- ->add('gender', ChoiceType::class, [
- 'label' => 'field.default.title',
- 'multiple' => false,
- 'expanded' => true,
- 'choices' => [
- 'field.default.madame' => 1,
- 'field.default.monsieur' => 0,
- ],
- 'translation_domain' => 'lcshop',
- ])
- ->add('firstName', TextType::class, [
- 'label' => 'field.default.firstname',
- 'translation_domain' => 'lcshop',
- ])
- ->add('lastName', TextType::class, [
- 'label' => 'field.default.lastname',
- 'translation_domain' => 'lcshop',
- ])
- ->add('phone', TextType::class, [
- 'label' => 'field.default.phone',
- 'translation_domain' => 'lcshop',
- ]);
-
- foreach($newsletters as $newsletter) {
- $builder->add('newsletter_'.$newsletter->getId(), CheckboxType::class, [
- //'label' => 'field.default.subscribeNewsletter',
- 'label' => $newsletter->getTitle(),
- 'required' => false,
- 'mapped' => false,
- 'translation_domain' => 'lcshop',
- 'help' => $newsletter->getDescription()
- ]);
- }
-
- // captcha
- $this->utils->addCaptchaType($builder);
- }
-
-
- }
|