Skip to content

Commit

Permalink
bug #1252 Improved templates to always include first the overridden t…
Browse files Browse the repository at this point in the history
…emplates (javiereguiluz)

This PR was squashed before being merged into the master branch (closes #1252).

Discussion
----------

Improved templates to always include first the overridden templates

This should fix #1241.

Commits
-------

2d9cb96 Improved templates to always include first the overridden templates
  • Loading branch information
javiereguiluz committed Oct 6, 2016
2 parents ce6494e + 2d9cb96 commit cf456b6
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 8 deletions.
5 changes: 4 additions & 1 deletion Resources/doc/book/3-list-search-show-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,10 @@ features. Inside these templates you have access to the following variables:
* `value`, the content of the property being rendered, which can be a variable
of any type (string, numeric, boolean, array, etc.)
* `view`, a string with the name of the view where the field is being rendered
(`show` or `list`).
(`show` or `list`);
* `entity_config`, an array with the full configuration of the currently
selected entity;
* `backend_config`, an array with the full backend configuration.
### Rendering Entity Properties with Custom Templates
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/default/field_array.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</ul>
{% else %}
<div class="empty collection-empty">
<span class="label label-empty">{{ 'label.empty'|trans({}, 'EasyAdminBundle') }}</span>
{{ include(entity_config.templates.label_empty) }}
</div>
{% endif %}
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/default/field_association.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ul>
{% else %}
<div class="empty collection-empty">
<span class="label label-empty">{{ 'label.empty'|trans({}, 'EasyAdminBundle') }}</span>
{{ include(entity_config.templates.label_empty) }}
</div>
{% endif %}
{% elseif 'list' == view %}
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/default/field_json_array.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</ul>
{% else %}
<div class="empty collection-empty">
<span class="label label-empty">{{ 'label.empty'|trans({}, 'EasyAdminBundle') }}</span>
{{ include(entity_config.templates.label_empty) }}
</div>
{% endif %}
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/default/field_simple_array.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</ul>
{% else %}
<div class="empty collection-empty">
<span class="label label-empty">{{ 'label.empty'|trans({}, 'EasyAdminBundle') }}</span>
{{ include(entity_config.templates.label_empty) }}
</div>
{% endif %}
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/form/bootstrap_3_layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@

{% block empty_collection %}
<div class="empty collection-empty">
<span class="label label-empty">{{ 'label.empty'|trans({}, 'EasyAdminBundle') }}</span>
{{ include(easyadmin.entity.templates.label_empty) }}
</div>
{% endblock empty_collection %}

Expand Down
8 changes: 7 additions & 1 deletion Twig/EasyAdminTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ public function renderEntityField(\Twig_Environment $twig, $view, $entityName, $
try {
$value = $this->propertyAccessor->getValue($item, $fieldName);
} catch (\Exception $e) {
return $twig->render($entityConfiguration['templates']['label_inaccessible'], array('view' => $view));
return $twig->render($entityConfiguration['templates']['label_inaccessible'], array(
'view' => $view,
'backend_config' => $this->getBackendConfiguration(),
'entity_config' => $entityConfiguration,
));
}

try {
Expand All @@ -117,6 +121,8 @@ public function renderEntityField(\Twig_Environment $twig, $view, $entityName, $
'item' => $item,
'value' => $value,
'view' => $view,
'backend_config' => $this->getBackendConfiguration(),
'entity_config' => $entityConfiguration,
);

if (null === $value) {
Expand Down
6 changes: 5 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ Upgrade to 2.0.0 (XX/XXX/201X)
Upgrade to 1.15.X (XX/October/2016)
-----------------------------------

* The template fragments used to render each property value (e.g.
`field_array.html.twig`, `label_null.html.twig`, etc.) now receive two new
variables called `entity_config` and `backend_config`, which are useful for
advanced backends.
* The `image` fields and the VichUploader files and images now are rendered
using the `asset()` Twig function. Depending on your configuration, you may
need to change or remove EasyAdmin's `base_path` option and define the proper
base path using Symfony's asset configuration.

Upgrade to 1.13.0 (11/May/2016)
-------------------------------
---------------------------------

* The configuration of the backend is no longer processed in a compiler pass
but generated with a cache warmer. This is done to avoid issues with Doctrine
Expand Down

0 comments on commit cf456b6

Please sign in to comment.