Изменить создание клиента sylius

Я хочу отредактировать создание клиента, я хочу добавить поле во время создания. При создании сервиса «Sylius.controller.customer: createAction» называется в 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

Однако я проверил много услуг sylius, я не нашел это.
Как я могу получить доступ к этому сервису, чтобы настроить создание?

Спасибо за ваше время.

0

Решение

Вы должны настроить форму, а не контроллер.
Вы можете найти подробную информацию здесь (настраивая форму sylius)

Идея заключается в следующем:

  1. Создайте расширение формы:


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;
}
}

  1. Зарегистрируйте это расширение как услугу в AppBundle/Resources/config/services.yml

  2. Добавьте соответствующие переводы и добавьте новый шаблон, чтобы показать новое поле

С уважением

0

Другие решения

Других решений пока нет …