Skip to content

Commit

Permalink
bug symfony#30509 [Form] Fix debug form when using partial type name …
Browse files Browse the repository at this point in the history
…(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
  • Loading branch information
nicolas-grekas committed Mar 13, 2019
2 parents f9d3848 + 22b20ca commit 5218979
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/Command/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
sort($options[$k]);
}
} else {
if (!class_exists($class)) {
if (!class_exists($class) || !is_subclass_of($class, FormTypeInterface::class)) {
$class = $this->getFqcnTypeClass($input, $io, $class);
}
$resolvedType = $this->formRegistry->getType($class);
Expand Down
9 changes: 9 additions & 0 deletions src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ public function testDebugSingleFormType()
$this->assertContains('Symfony\Component\Form\Extension\Core\Type\FormType (Block prefix: "form")', $tester->getDisplay());
}

public function testDebugDateTimeType()
{
$tester = $this->createCommandTester();
$tester->execute(['class' => 'DateTime'], ['decorated' => false, 'interactive' => false]);

$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
$this->assertContains('Symfony\Component\Form\Extension\Core\Type\DateTimeType (Block prefix: "datetime")', $tester->getDisplay());
}

public function testDebugFormTypeOption()
{
$tester = $this->createCommandTester();
Expand Down

0 comments on commit 5218979

Please sign in to comment.