Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

142
Visualizações
Edit customer creation sylius

I want to edit the creation of a customer, I want to add a field during the creation. During the creation the service "sylius.controller.customer:createAction" is called in security.yml

sylius_shop_register:
    path: /register
    methods: [GET, POST]
    defaults:
        _controller: sylius.controller.customer:createAction
        _sylius:
            template: "@SyliusShop/register.html.twig"
            form: Sylius\Bundle\CoreBundle\Form\Type\Customer\CustomerRegistrationType
            event: register
            redirect:
                route: sylius_shop_account_dashboard
            flash: sylius.customer.register

However I checked a lot of sylius services I didn't find it. How can I acces to this service to custom the creation ?

Thanks for your time.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You should customize the form and not the controler. You can find detailed information here (sylius customizing form)

The idea is:

  1. Create a form extension:

    final class CustomerRegistrationType extends AbstractTypeExtension
        {
            /**
         * {@inheritdoc}
         */
        public function buildForm(FormBuilderInterface $builder, array $options)
        {
            // Adding new fields works just like in the parent form type.
            $builder->add('YourField', TextType::class, [
                'required' => false,
                'label' => 'app.form.customer.yourfield',
            ]);
        }
        /**
         * {@inheritdoc}
         */
        public function getExtendedType()
        {
            return CustomerRegistrationType::class;
        }
    }
    
  2. Register this extension as a service in the AppBundle/Resources/config/services.yml

  3. Add according translations, and add a new template to show your new field

Regards

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda