Skip to content

Commit 33a2fc5

Browse files
authored
#11272 extend example for createNamed function
1 parent 447a4c3 commit 33a2fc5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

forms.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -680,13 +680,17 @@ choice is ultimately up to you.
680680

681681
// src/AppBundle/Controller/DefaultController.php
682682
use AppBundle\Form\TaskType;
683+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
683684

684-
public function newAction()
685+
class DefaultController extends AbstractController
685686
{
686-
$task = ...;
687-
$form = $this->container->get('form.factory')->createNamed('name', TaskType::class, $task);
687+
public function newAction()
688+
{
689+
$task = ...;
690+
$form = $this->get('form.factory')->createNamed('name', TaskType::class, $task);
688691

689-
// ...
692+
// ...
693+
}
690694
}
691695

692696
You can even suppress the name completely by setting it to an empty string.

0 commit comments

Comments
 (0)