8000 [Form] add a convenience method to get the parent form in Twig templates by xabbuh · Pull Request #28812 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] add a convenience method to get the parent form in Twig templates #28812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Symfony/Bridge/Twig/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
-----

Expand Down
9 changes: 9 additions & 0 deletions src/Symfony/Bridge/Twig/Extension/FormExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function getFunctions()
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'),
];
}

Expand Down Expand Up @@ -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;
}
0