diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php index e25dacf237d02..4a5a1df6af212 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php @@ -24,6 +24,11 @@ class FixUrlProtocolListener implements EventSubscriberInterface { private $defaultProtocol; + /** + * Constructor. + * + * @param string|null $defaultProtocol The URL scheme to add when there is none or null to not modify the data + */ public function __construct($defaultProtocol = 'http') { $this->defaultProtocol = $defaultProtocol; diff --git a/src/Symfony/Component/Form/Extension/Core/Type/UrlType.php b/src/Symfony/Component/Form/Extension/Core/Type/UrlType.php index b79809259f7cb..5c414afc932b7 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/UrlType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/UrlType.php @@ -23,7 +23,9 @@ class UrlType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->addEventSubscriber(new FixUrlProtocolListener($options['default_protocol'])); + if (null !== $options['default_protocol']) { + $builder->addEventSubscriber(new FixUrlProtocolListener($options['default_protocol'])); + } } /**
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: