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
-------
cb60642d15
add a convenience method to get the parent form in Twig templates
This commit is contained in:
commit
c6a2c3348f
@ -1,6 +1,11 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
4.3.0
|
||||
-----
|
||||
|
||||
* added the `parent_form()` function that allows to reliably retrieve the parent form in Twig templates
|
||||
|
||||
4.2.0
|
||||
-----
|
||||
|
||||
|
@ -54,6 +54,7 @@ class FormExtension extends AbstractExtension
|
||||
new TwigFunction('form_start', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
|
||||
new TwigFunction('form_end', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
|
||||
new TwigFunction('csrf_token', ['Symfony\Component\Form\FormRenderer', 'renderCsrfToken']),
|
||||
new TwigFunction('parent_form', 'Symfony\Bridge\Twig\Extension\twig_get_parent_form'),
|
||||
];
|
||||
}
|
||||
|
||||
@ -115,3 +116,11 @@ function twig_is_root_form(FormView $formView)
|
||||
{
|
||||
return null === $formView->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function twig_get_parent_form(FormView $formView): ?FormView
|
||||
{
|
||||
return $formView->parent;
|
||||
}
|
||||
|
Reference in New Issue
Block a user