php - Edit customer creation in 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 insecurity.yml

    path: /register
    methods: [GET, POST]
        _controller: sylius.controller.customer:createAction
            template: "@SyliusShop/register.html.twig"
            form: Sylius\Bundle\CoreBundle\Form\Type\Customer\CustomerRegistrationType
            event: register
                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 access to this service to custom the creation ?

Thanks for your time.




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 theAppBundle/Resources/config/services.yml

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


People are also looking for solutions to the problem: php - "Comment not terminated" XML parsing error in Box API response


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.