Skip to content

Commit b1e6940

Browse files
authored
Merge pull request #1272 from nacorp/make-crud-depreciation-renderform
[make:crud] render or renderForm - Avoid deprecations in 6.2
2 parents 3619800 + c181d10 commit b1e6940

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/Maker/MakeCrud.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
use Symfony\Component\Form\AbstractType;
3939
use Symfony\Component\HttpFoundation\Request;
4040
use Symfony\Component\HttpFoundation\Response;
41+
use Symfony\Component\HttpKernel\Kernel;
4142
use Symfony\Component\Routing\Annotation\Route;
4243
use Symfony\Component\Security\Csrf\CsrfTokenManager;
4344
use Symfony\Component\Validator\Validation;
@@ -179,7 +180,8 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
179180
'entity_var_singular' => $entityVarSingular,
180181
'entity_twig_var_singular' => $entityTwigVarSingular,
181182
'entity_identifier' => $entityDoctrineDetails->getIdentifier(),
182-
'use_render_form' => method_exists(AbstractController::class, 'renderForm'),
183+
// @legacy - Remove when support for Symfony <6 is dropped
184+
'use_render_form' => Kernel::VERSION_ID < 62000,
183185
],
184186
$repositoryVars
185187
)

src/Resources/skeleton/crud/controller/Controller.tpl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function new(Request $request, EntityManagerInterface $entityManager): Re
6262
<?php } else { ?>
6363
return $this->render('<?= $templates_path ?>/new.html.twig', [
6464
'<?= $entity_twig_var_singular ?>' => $<?= $entity_var_singular ?>,
65-
'form' => $form->createView(),
65+
'form' => $form,
6666
]);
6767
<?php } ?>
6868
}
@@ -107,7 +107,7 @@ public function edit(Request $request, <?= $entity_class_name ?> $<?= $entity_va
107107
<?php } else { ?>
108108
return $this->render('<?= $templates_path ?>/edit.html.twig', [
109109
'<?= $entity_twig_var_singular ?>' => $<?= $entity_var_singular ?>,
110-
'form' => $form->createView(),
110+
'form' => $form,
111111
]);
112112
<?php } ?>
113113
}

0 commit comments

Comments
 (0)