/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventSubscriber(new AddCodeFormSubscriber())->add('translations', ResourceTranslationsType::class, ['entry_type' => $this->attributeTranslationType, 'label' => 'sylius.form.attribute.translations'])->add('type', AttributeTypeChoiceType::class, ['label' => 'sylius.form.attribute.type', 'disabled' => true]);
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$attribute = $event->getData();
if (!$attribute instanceof AttributeInterface) {
return;
}
if (!$this->formTypeRegistry->has($attribute->getType(), 'configuration')) {
return;
}
$event->getForm()->add('configuration', $this->formTypeRegistry->get($attribute->getType(), 'configuration'), ['auto_initialize' => false, 'label' => 'sylius.form.attribute_type.configuration']);
});
}