Skip to content

Commit 5218979

Browse files
bug symfony#30509 [Form] Fix debug form when using partial type name (yceruto)
This PR was merged into the 4.3-dev branch. Discussion ---------- [Form] Fix debug form when using partial type name | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT Since symfony#29452 (4.3) we have the possibility of passing a partial type name. This fixes the case where `debug:form dateTime` doesn't work as expected: ```bash In FormRegistry.php line 89: [Symfony\Component\Form\Exception\InvalidArgumentException] Could not load type "dateTime": class does not implement "Symfony\Component\Form\FormTypeInterface". ``` Commits ------- 22b20ca Fix debug:form dateTime
2 parents f9d3848 + 22b20ca commit 5218979

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Symfony/Component/Form/Command/DebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
115115
sort($options[$k]);
116116
}
117117
} else {
118-
if (!class_exists($class)) {
118+
if (!class_exists($class) || !is_subclass_of($class, FormTypeInterface::class)) {
119119
$class = $this->getFqcnTypeClass($input, $io, $class);
120120
}
121121
$resolvedType = $this->formRegistry->getType($class);

src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ public function testDebugSingleFormType()
6666
$this->assertContains('Symfony\Component\Form\Extension\Core\Type\FormType (Block prefix: "form")', $tester->getDisplay());
6767
}
6868

69+
public function testDebugDateTimeType()
70+
{
71+
$tester = $this->createCommandTester();
72+
$tester->execute(['class' => 'DateTime'], ['decorated' => false, 'interactive' => false]);
73+
74+
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
75+
$this->assertContains('Symfony\Component\Form\Extension\Core\Type\DateTimeType (Block prefix: "datetime")', $tester->getDisplay());
76+
}
77+
6978
public function testDebugFormTypeOption()
7079
{
7180
$tester = $this->createCommandTester();

0 commit comments

Comments
 (0)