Using Symfony 4.1 with EasyAdmin bundle.
I am trying to override a template for the User (one of my entites) show view. I have set up the override and it is working.
Created a user_show.html.twig and registered it in the easy_admin config file.
I then copy the twig blocks from corresponding bundle template for show.html.twig.
Then tried to render a User property from my user entity, called profile height.
Here are twig blocks I'm overriding:
{# templates/admin/user_show.html.twig #}
{% extends '@EasyAdmin/default/show.html.twig' %}
{% block content_title %}
Test Title {{ dump() }}
{% endblock %}
{% block main %}
{{ profileHeight }}
{% endblock %}
Error
Twig_Error_Runtime: Variable "profileHeight" does not exist
Debug
I did a dump and found the property is present on page:
Why can twig not see these variables appearing in the dump? How can I render the properties I want in the template?
As you can see in your dumped data, there is entity
array key which hold the User
object. So instead of:
{% block main %}
{{ profileHeight }}
{% endblock %}
Use:
{% block main %}
{{ entity.profileHeight }}
{% endblock %}