Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 51cfaf8

Browse filesBrowse files
committed
minor #24740 [Form] Nullable FormInterface::getPropertyPath() (vudaltsov)
This PR was merged into the 2.7 branch. Discussion ---------- [Form] Nullable FormInterface::getPropertyPath() | Q | A | ------------- | --- | Branch? | 4.0 | Bug fix? | yes | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #24560 | License | MIT | Doc PR | `Symfony\Component\Form\Form::getPropertyPath()` returns `null` when the form has an empty name. It allows for unprefixed children. ```php <?php namespace App\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\TextType; class IndexController extends AbstractController { /** * @route(name="index") * @template() */ public function indexAction() { $form = $this->get('form.factory') ->createNamedBuilder('') ->add('text', TextType::class) ->getForm(); return [ 'form' => $form->createView(), ]; } } ``` ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Welcome!</title> </head> <body> <form name="" method="post"> <label for="text">Text</label> <input type="text" id="text" name="text"> </form> </body> </html> ``` But the return type of the `Symfony\Component\Form\FormInterface::getPropertyPath()` is not nullable. We cannot change the behaviour, obviously. At least it's useful in API controllers. So I decided to change the doc block of the interface. Commits ------- d56632a FormInterface::getPropertyPath(): PropertyPathInterface|null
2 parents 5a3db67 + d56632a commit 51cfaf8
Copy full SHA for 51cfaf8

File tree

1 file changed

+1
-1
lines changed
Filter options

1 file changed

+1
-1
lines changed

‎src/Symfony/Component/Form/FormInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/FormInterface.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function getName();
171171
/**
172172
* Returns the property path that the form is mapped to.
173173
*
174-
* @return \Symfony\Component\PropertyAccess\PropertyPathInterface The property path
174+
* @return \Symfony\Component\PropertyAccess\PropertyPathInterface|null The property path
175175
*/
176176
public function getPropertyPath();
177177

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.