public function buildConfigField(FormEvent $event)
    {
        /** @var array $data */
        $data = $event->getData();
        if (is_null($data)) {
            return;
        }

        $propertyPath = is_array($data) ? '[factoryName]' : 'factoryName';
        $factoryName = PropertyAccess::createPropertyAccessor()->getValue($data, $propertyPath);
        if (empty($factoryName)) {
            return;
        }

        $paymentFactory = $this->registry->getGatewayFactory($factoryName);
        $config = $paymentFactory->createConfig();

        if (empty($config['payum.default_options'])) {
            return;
        }

        $form = $event->getForm();
        $form->add('config', 'form', [
            'label' => 'ekyna_core.field.config',
        ]);
        $configForm = $form->get('config');

        $propertyPath = is_array($data) ? '[config]' : 'config';
        $firstTime = false == PropertyAccess::createPropertyAccessor()->getValue($data, $propertyPath);
        foreach ($config['payum.default_options'] as $name => $value) {
            $propertyPath = is_array($data) ? "[config][$name]" : "config[$name]";
            if ($firstTime) {
                PropertyAccess::createPropertyAccessor()->setValue($data, $propertyPath, $value);
            }

            $type = 'text';
            $options = array();
            if (is_bool($value)) {
                $type = 'checkbox';
                $options['attr'] = ['align_with_widget' => true];
            } elseif(is_numeric($value)) {
                $type = is_float($value) ? 'number' : 'integer';
            } elseif (is_array($value)) {
                continue;
            }

            $options['required'] = in_array($name, $config['payum.required_options']);

            $configForm->add($name, $type, $options);
        }

        $event->setData($data);
    }