Skip to content

[Form] renderForm() method is deprecated #16948

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

Closed

Conversation

mdoutreluingne
Copy link
Contributor

Fixes #16942

@@ -21,7 +21,7 @@ enough to render an entire form, including all its fields and error messages:
.. code-block:: twig

{# form is a variable passed from the controller via either
$this->renderForm('...', ['form' => $form])
$this->render('...', ['form' => $form])
or $this->render('...', ['form' => $form->createView()]) #}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line unfortunately won't work the same symfony/symfony#46854 (comment). We need to be careful.

I propose to keep this PR open until I (or anyone) try to tackle this in core.

Copy link
Contributor Author

@mdoutreluingne mdoutreluingne Jul 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I created this PR because currently in 6.2 the renderForm method is obsolete (so the documentation is acutely wrong). This branch is still under development and can therefore indeed be further modified. If you modify this method, don't forget to ping me so that I can close this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that both methods also weren't doing the same thing before this change. So I don't see this change blocking this PR.

forms.rst Outdated
'form' => $form,
]);
}
}

In versions prior to Symfony 5.3, controllers used the method
``$this->render('...', ['form' => $form->createView()])`` to render the form.
The ``renderForm()`` method abstracts this logic and it also sets the 422 HTTP
The ``render()`` method abstracts this logic and it also sets the 422 HTTP
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may not (see my comment above).

@HeahDude
Copy link
Contributor

HeahDude commented Jul 7, 2022

Thank you @mdoutreluingne for that PR.

@javiereguiluz
Copy link
Member

Just checking: are we still waiting for some code changes before finishing this PR? Thanks!

@HeahDude
Copy link
Contributor

Yes, I'll ping when there will be an update :).

@HeahDude
Copy link
Contributor

Minor update: I've opened symfony/symfony#47600, let's see how it goes.

@wouterj wouterj closed this Sep 20, 2022
@wouterj wouterj force-pushed the renderform-function-deprec branch from a8a24f6 to 0c39faf Compare September 20, 2022 12:22
wouterj added a commit that referenced this pull request Sep 20, 2022
…ngne)

This PR was merged into the 6.2 branch.

Discussion
----------

[Form] `renderForm()` method is deprecated

Fixes #16942

Commits
-------

0c39faf Deprecate `renderForm()`
@wouterj
Copy link
Member

wouterj commented Sep 20, 2022

Thanks @mdoutreluingne for writing up the documentation for this change!

I've added some changes to your commit, to be more clear about the current situation and the differences between passing $form and $form->createView(). Unfortunately, GitHub does not correctly show the changes. You can view the new commit (which was merged) here: 0c39faf

@mdoutreluingne mdoutreluingne deleted the renderform-function-deprec branch September 20, 2022 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FrameworkBundle] Make AbstractController::render() able to deal with…
5 participants