8000 feature #28812 [Form] add a convenience method to get the parent form… · symfony/symfony@c6a2c33 · GitHub
[go: up one dir, main page]

Skip to content

Commit c6a2c33

Browse files
committed
feature #28812 [Form] add a convenience method to get the parent form in Twig templates (xabbuh)
This PR was merged into the 4.3-dev branch. Discussion ---------- [Form] add a convenience method to get the parent form in Twig templates | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28686 | License | MIT | Doc PR | Commits ------- cb60642 add a convenience method to get the parent form in Twig templates
2 parents 03dfdc4 + cb60642 commit c6a2c33

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Symfony/Bridge/Twig/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.3.0
5+
-----
6+
7+
* added the `parent_form()` function that allows to reliably retrieve the parent form in Twig templates
8+
49
4.2.0
510
-----
611

src/Symfony/Bridge/Twig/Extension/FormExtension.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function getFunctions()
5454
new TwigFunction('form_start', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
5555
new TwigFunction('form_end', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
5656
new TwigFunction('csrf_token', ['Symfony\Component\Form\FormRenderer', 'renderCsrfToken']),
57+
new TwigFunction('parent_form', 'Symfony\Bridge\Twig\Extension\twig_get_parent_form'),
5758
];
5859
}
5960

@@ -115,3 +116,11 @@ function twig_is_root_form(FormView $formView)
115116
{
116117
return null === $formView->parent;
117118
}
119+
120+
/**
121+
* @internal
122+
*/
123+
function twig_get_parent_form(FormView $formView): ?FormView
124+
{
125+
return $formView->parent;
126+
}

0 commit comments

Comments
 (0)
0