Skip to content
Permalink
Browse files

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
  • Loading branch information
fabpot committed Feb 13, 2019
2 parents 03dfdc4 + cb60642 commit c6a2c3348fc3837143eb8f4f9256e0d015047fc7
Showing with 14 additions and 0 deletions.
  1. +5 −0 src/Symfony/Bridge/Twig/CHANGELOG.md
  2. +9 −0 src/Symfony/Bridge/Twig/Extension/FormExtension.php
@@ -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 @@ 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'),
];
}
@@ -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 comments on commit c6a2c33

Please sign in to comment.
You can’t perform that action at this time.