-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Nullable FormInterface::getPropertyPath() #24740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Form] Nullable FormInterface::getPropertyPath() #24740
Conversation
For 2.7? Merging that for 4.0 only is suspicious. |
Is this a bc-break? Technically yes. Because I've changed the signature of the interface. But on the other hand null was possible because static typing was not used... |
Fine for me on 2.7. |
d3d0daa
to
d56632a
Compare
@chalasr, rebased onto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, that's a BC break. But the main implementation already had this behaviour.
Thank you @vudaltsov. |
…sov) 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
Symfony\Component\Form\Form::getPropertyPath()
returnsnull
when the form has an empty name. It allows for unprefixed children.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.