Repository navigation
Conversation
phcorp
force-pushed
the
fix_url_field_default_protocol
branch
2 times, most recently
from
November 7, 2026 02:06
42f3d84 to
f703ff3
Compare
UrlConfigurator always set the 'default_protocol' form option, which only
UrlType (and the types extending it) defines. Rendering a UrlField with
another form type, e.g. UrlField::new('website')->setFormType(TextType::class)
to keep the URL rendering on index/detail pages but use a plain text input,
failed with an UndefinedOptionsException.
The configurator now asks the form registry whether the field's form type
defines the option before setting it, so types whose parent is UrlType
keep receiving it.
phcorp
force-pushed
the
fix_url_field_default_protocol
branch
from
November 8, 2026 19:51
f703ff3 to
742b886
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
UrlConfiguratoralways sets thedefault_protocolform option. OnlyUrlType(and the types whose parent isUrlType) defines it, so aUrlFieldrendered with another form type fails when the form is built:Fix
Before setting the option, the configurator asks the form registry whether the field's form type defines
default_protocol(FormRegistryInterface::getType($type)->getOptionsResolver()->isDefined(...)). So:UrlTypebehaves as beforeUrlTypethroughgetParent()keep receiving the optionTextType) no longer get itUrlConfiguratorgetsform.registryas a constructor argument inconfig/services.php.Tests
tests/Unit/Field/UrlFieldTest.php:testDefaultProtocolOptionIsNotSetWhenFormTypeDoesNotDefineIt()(TextType)testDefaultProtocolOptionIsSetWhenFormTypeExtendsUrlType()(a test type whose parent isUrlType)default_protocoltests still pass withUrlTypeResults:
make tests ARGS="tests/Unit/Field/UrlFieldTest.php": OK (52 tests)make tests ARGS="tests/Unit/Field tests/Functional/Fields": OKmake tests-parallel: OK (3688 tests)