Overwriting a field of AdmingeneratorGeneratorBundle
-
05-06-2021 - |
سؤال
I am trying to overwrite a field of the AdmingeneratorGeneratorBundle and want to append a link to a certain field. That works quite well following the documentation:
{% extends_admingenerated "MyMainBundle:PageEdit:index.html.twig" %}
{% block form_status %}
{{ parent() }}
<a href="{{ path("_admin_preview", {'id': 8, '_format': 'pdf'}) }}">Preview</a>
{% endblock %}
What I would need to do now, is to get the real id of my page instead of the static 8, but i could not figure out, what the object is called inside the twig template. Any ideas?
Update: In my case, as I only need the ID of my page, I can use app.request.attributes.get('pk') to get it in twig. Would be interesting how to get other values tough.
المحلول
Just use
{% extends_admingenerated "MyMainBundle:PageEdit:index.html.twig" %}
{% block form_status %}
{{ parent() }}
<a href="{{ path("_admin_preview", {'id': Movie.Id, '_format': 'pdf'}) }}">Preview</a>
{% endblock %}
Cedric
نصائح أخرى
The Documentation has been updated.
Thats ho it works:
{% extends_admingenerated "NamespaceYourBundle:List:index.html.twig" %}
{% block list_td_column_title %}
<span style="font-weight:bold">{{ Movie.title }}</span>
{% endblock %}
لا تنتمي إلى StackOverflow