10000 Form templates overrides do not work in /templates · Issue #25661 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Form templates overrides do not work in /templates #25661

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

Closed
nesl247 opened this issue Jan 3, 2018 · 4 comments
Closed

Form templates overrides do not work in /templates #25661

nesl247 opened this issue Jan 3, 2018 · 4 comments

Comments

@nesl247
Copy link
nesl247 commented Jan 3, 2018
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.4.2

With #24179 the default_path configuration key was added. Part of this was to allow bundle overrides in /templates/<BundleName>. However, this doesn't appear to be working for Form templates.

Specifically templates in templates/bundles/BundleName/Form/something.html.twig does not override the original. In my case this is for https://github.com/excelwebzone/EWZRecaptchaBundle but I'm guessing this would apply to any Form templates.

@xabbuh
Copy link
Member
xabbuh commented Jan 3, 2018

Can you create a small example application that allows to reproduce the issue?

@yceruto
Copy link
Member
yceruto commented Jan 3, 2018

This looks like the referenced bundle use Templating Component and its corresponding syntax to configure the form theme template EWZRecaptchaBundle:Form:ewz_recaptcha_widget.html.twig, which is not compatible with the overriding mechanism of Twig (i.e they are different templates loaders).

In that case you must put your custom template in app/Resources/EWZRecaptchaBundle/views/Form/ewz_recaptcha_widget.html.twig (http://symfony.com/doc/3.4/templating/overriding.html). To use the modern way (templates/bundles/...) the bundle should configure it by using the Twig's syntax instead: @EWZRecaptcha\Form\ewz_recaptcha_widget.html.twig.

@nesl247
Copy link
Author
nesl247 commented Jan 3, 2018

Aah gotcha. I completely forgot about the format differences in the template name. That would definitely explain it. I'll go ahead and close this issue.

I had resolved it already by using src/Resources/EWZRecaptchaBundle/views, so at least that works.

@phoenixgao
Copy link

It took me half day to finally reach here... if this information could be added to the documentation it would be perfect @yceruto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0