Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ro0NL commentedOct 11, 2018
it's a BC break no? also ref#19492 (comment) |
xabbuh commentedOct 11, 2018
Why would that be a BC break? |
xabbuh commentedOct 11, 2018
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 |
ro0NL commentedOct 11, 2018
the order changes right? before a child named parent might be returned first, whereas now it's always the parent form |
ro0NL commentedOct 11, 2018
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 :) |
xabbuh commentedOct 11, 2018
If you refer to
I don't think that's a good idea DX wise. Being able to use |
yceruto commentedOct 11, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@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 publicfunctiongetPropertyValue($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')isnull %}{# $formView->vars#}{%if property_value(form,'vars').attr.classisdefined %} even, other |
xabbuh commentedOct 31, 2018
I have rewritten this solution to add a new |
Uh oh!
There was an error while loading.Please reload this page.
javiereguiluz commentedNov 7, 2018
@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! |
fabpot commentedFeb 13, 2019
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
xabbuh commentedFeb 16, 2019
@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 functiondocumentssymfony/symfony#28812Commits-------2ea9797 document the parent_form() Twig function
Uh oh!
There was an error while loading.Please reload this page.