Skip to content

Commit fa90894

Browse files
committed
[Form] Change default_protocol default value to null in UrlType
1 parent 6ab4a14 commit fa90894

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

UPGRADE-8.0.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,30 @@ DoctrineBridge
131131
$type = $extractor->getType(Foo::class, 'property');
132132
```
133133

134+
Form
135+
----
136+
137+
* The `default_protocol` option in `UrlType` now defaults to `null` instead of `'http'`
138+
139+
*Before*
140+
```php
141+
// URLs without protocol were automatically prefixed with 'http://'
142+
$builder->add('website', UrlType::class);
143+
// Input: 'example.com' → Value: 'http://example.com'
144+
```
145+
146+
*After*
147+
```php
148+
// URLs without protocol are now kept as-is
149+
$builder->add('website', UrlType::class);
150+
// Input: 'example.com' → Value: 'example.com'
151+
152+
// To restore the previous behavior, explicitly set the option:
153+
$builder->add('website', UrlType::class, [
154+
'default_protocol' => 'http',
155+
]);
156+
```
157+
134158
FrameworkBundle
135159
---------------
136160

src/Symfony/Component/Form/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
8.0
5+
---
6+
7+
* Change default value of `default_protocol` option in `UrlType` from `'http'` to `null`
8+
49
7.4
510
---
611

src/Symfony/Component/Form/Extension/Core/Type/UrlType.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ public function buildView(FormView $view, FormInterface $form, array $options):
3939
public function configureOptions(OptionsResolver $resolver): void
4040
{
4141
$resolver->setDefaults([
42-
'default_protocol' => static function (Options $options) {
43-
trigger_deprecation('symfony/form', '7.1', 'Not configuring the "default_protocol" option when using the UrlType is deprecated. It will default to "null" in 8.0.');
44-
45-
return 'http';
46-
},
42+
'default_protocol' => null,
4743
'invalid_message' => 'Please enter a valid URL.',
4844
]);
4945

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy