Skip to content

Update Controller.tpl.php to use createView() method by default #1709

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

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions templates/crud/controller/Controller.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function new(Request $request, EntityManagerInterface $entityManager): Re

return $this->render('<?= $templates_path ?>/new.html.twig', [
'<?= $entity_twig_var_singular ?>' => $<?= $entity_var_singular ?>,
'form' => $form,
'form' => $form->createView(),
Copy link

Choose a reason for hiding this comment

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

render() will automatically call createView() on all parameters that are an instance of FormInterface!

Copy link
Author

Choose a reason for hiding this comment

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

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! :)

]);
}

Expand All @@ -71,7 +71,7 @@ public function edit(Request $request, <?= $entity_class_name ?> $<?= $entity_va

return $this->render('<?= $templates_path ?>/edit.html.twig', [
'<?= $entity_twig_var_singular ?>' => $<?= $entity_var_singular ?>,
'form' => $form,
'form' => $form->createView(),
]);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/make-crud/expected/WithCustomRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function new(Request $request, EntityManagerInterface $entityManager): Re

return $this->render('sweet_food/new.html.twig', [
'sweet_food' => $sweetFood,
'form' => $form,
'form' => $form->createView(),
]);
}

Expand All @@ -64,7 +64,7 @@ public function edit(Request $request, SweetFood $sweetFood, EntityManagerInterf

return $this->render('sweet_food/edit.html.twig', [
'sweet_food' => $sweetFood,
'form' => $form,
'form' => $form->createView(),
]);
}

Expand Down
Loading