Skip to content
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

2.11 error - Template cannot be used as a trait #3051

Closed
acrobat opened this issue Jun 4, 2019 · 11 comments · Fixed by #3054
Closed

2.11 error - Template cannot be used as a trait #3051

acrobat opened this issue Jun 4, 2019 · 11 comments · Fixed by #3054

Comments

@acrobat
Copy link

acrobat commented Jun 4, 2019

After upgrading to twig 2.11.1 (from 2.10.x) the code below throws an error, in previous versions it worked fine.

{% block datetime_widget %}
    {% use 'form_div_layout.html.twig' with datetime_widget as base_datetime_widget %}    
    <div class="form-group date-time-group">
        {{ block('base_datetime_widget') }}
    </div>
{% endblock %}

The error:

Template "form_div_layout.html.twig" cannot be used as a trait.
@fabpot
Copy link
Contributor

fabpot commented Jun 4, 2019

Can you create a template that reproduce this issue (via https://twigfiddle.com/ if possible)?

@daum
Copy link

daum commented Jun 4, 2019

FYI I am getting this too after upgrading, this is coming from the symfony 4.2.9 bootstrap_4 form theme template (globally), specifically the base one causes the error. Downgrading to 2.10.0 fixes the issue. Working on making a reproducible example that I can make public.

@fabpot one thing I did notice is if I load via a request to my application with no cache, it works fine and the isTraitable is true, but if going from CC it is showing as false.

Will report back when I have a way to reproduce, but most likely won't have time to look until later this week.

@fabpot
Copy link
Contributor

fabpot commented Jun 5, 2019

I had the issue on one of my projects and upgrading to v2.11.1 and removing the cache did work.

@acrobat
Copy link
Author

acrobat commented Jun 5, 2019

@fabpot manually removing the cache does indeed seem to work, strange that a cache-clear after composer update didn't resolve this issue

@acrobat
Copy link
Author

acrobat commented Jun 5, 2019

@fabpot It seems that manually removing the cache or a cache:clear --no-warmup doens't trigger this error but a regular cache:clear will trigger it.

@fabpot fabpot mentioned this issue Jun 5, 2019
@fabpot
Copy link
Contributor

fabpot commented Jun 5, 2019

#3051 should fix the problem. @acrobat Can you confirm?

@acrobat
Copy link
Author

acrobat commented Jun 5, 2019

@fabpot #3054 seems to fix the issue! The exception is not throw after a regular cache:clear. Thanks!

@daum
Copy link

daum commented Jun 5, 2019

confirmed fixes here too.

@fabpot fabpot closed this as completed Jun 5, 2019
fabpot added a commit that referenced this issue Jun 5, 2019
This PR was merged into the 2.x branch.

Discussion
----------

Fix typo

closes #3051

Commits
-------

57c5130 fixed macro auto-import
@fabpot
Copy link
Contributor

fabpot commented Jun 5, 2019

2.11.2 with the fix released

@lchhieu
Copy link

lchhieu commented Sep 16, 2019

same error. How to fix this error?

@acrobat
Copy link
Author

acrobat commented Sep 16, 2019

@lchhieu Updating twig to atleast 2.11.2 should fix this issue.

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

Successfully merging a pull request may close this issue.

4 participants