add a convenience method to get the parent form in Twig templates
This commit is contained in:
parent
5aa0967f9f
commit
cb60642d15
@ -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