Update Controller.tpl.php to use createView() method by default#1709
Open
DocFX wants to merge 1 commit intosymfony:1.xfrom
Open
Update Controller.tpl.php to use createView() method by default#1709DocFX wants to merge 1 commit intosymfony:1.xfrom
DocFX wants to merge 1 commit intosymfony:1.xfrom
Conversation
ker0x
reviewed
Jun 4, 2025
| return $this->render('<?= $templates_path ?>/new.html.twig', [ | ||
| '<?= $entity_twig_var_singular ?>' => $<?= $entity_var_singular ?>, | ||
| 'form' => $form, | ||
| 'form' => $form->createView(), |
There was a problem hiding this comment.
render() will automatically call createView() on all parameters that are an instance of FormInterface!
Author
There was a problem hiding this comment.
I know that it does... If not yet done. The question is: shouldn't this be done?
Pros: more explicit.
Cons: doesn't handle the 422 code, for instance (like Turbo doesn't like this).
I'm split on that. Hence the questioning! :)
Author
|
Annnd... The test runner crashed :( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, just stumble recurringly on this while using
make:crud.There are several ways to address that, like using render() or else, but I think the most concensual way of doing so would be to just add
createView()to all Controller methods that pass forms to templates.I might be wrong on that, though, but it's one of the first things I do in those files right after generating them.