[Form] add a convenience method to get the parent form in Twig templates#28812
[Form] add a convenience method to get the parent form in Twig templates#28812fabpot merged 1 commit intosymfony:masterfrom
Conversation
|
it's a BC break no? also ref #19492 (comment) |
|
Why would that be a BC break? |
|
Taking into account #19492 (comment) we could of course think about adding a Twig function instead if we do not want to add this method to the |
|
the order changes right? before a child named parent might be returned first, whereas now it's always the parent form |
|
alternatively, getting rid of arrayaccess in formview would also do it towards consistent accessors in php as well as twig, but that's a bigger step :) |
|
If you refer to
I don't think that's a good idea DX wise. Being able to use |
|
@xabbuh could we deprecating In the other hand, I think the solution should be done in Twig context, because having a getter for a public property seems odd. What about adding a new Twig function for access to the public function getPropertyValue($object, string $propertyName)
{
return $object->$propertyName;
}for cases where the public property matches the name of the child form ( {# $formView->parent #}
{% if property_value(form, 'parent') is null %}
{# $formView->vars #}
{% if property_value(form, 'vars').attr.class is defined %}even, other |
|
I have rewritten this solution to add a new |
|
@xabbuh please, create an issue in Symfony Docs to not forget about this. Also, please add some usage examples and if this improves an existing feature add a before/after example. Finally, please check if this fixes something that the current docs say it's not possible to do or buggy. Thanks! |
|
Thank you @xabbuh. |
… 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
|
@javiereguiluz it took me some time, but here we go now: symfony/symfony-docs#10999 |
This PR was merged into the master branch. Discussion ---------- document the parent_form() Twig function documents symfony/symfony#28812 Commits ------- 2ea9797 document the parent_form() Twig function
Uh oh!
There was an error while loading. Please reload this page.