idea-php-symfony2-plugin
idea-php-symfony2-plugin copied to clipboard
False positive "Symfony: Create a form view for passing to template" when using `renderForm`
Description
Since Symfony 5.3, a controller can call the method renderForm
and doesn't have to create the FormView
when passing a FormInterface
to a template.
When using this method (So I not calling $form->createView()
when passing $form to the template), I have a warning Symfony: Create a form view for passing to template
.
PhpStorm version: 2022.1, build #PS-221.5080.224 PhpStorm Symfony plugin version: 2022.1.221
Same here, BTW when:
...
'form' => $form->createView()
...
the message is gone, but Symfony error occurs: Passing a FormView to "App\Controller\FooController::renderForm()" is not supported, pass directly the form instead for parameter "form".
Update: see @tip2tail below for Symfony 6.
As a workaround, you can disable inspection for Symfony: Create a form view for passing to template
In Settings > Editor > Inspection
search for "Symfony"
renderForm
has been deprecated in Symfony 6 now, and you should be able to pass the form object direct to render
- so another case that needs to be catered for on this issue.