diff --git a/Resources/doc/book/3-list-search-show-configuration.md b/Resources/doc/book/3-list-search-show-configuration.md index d6f3a698de..e652b7a24e 100644 --- a/Resources/doc/book/3-list-search-show-configuration.md +++ b/Resources/doc/book/3-list-search-show-configuration.md @@ -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 diff --git a/Resources/views/default/field_array.html.twig b/Resources/views/default/field_array.html.twig index 8d3c4270bb..be50a4c4bb 100644 --- a/Resources/views/default/field_array.html.twig +++ b/Resources/views/default/field_array.html.twig @@ -7,7 +7,7 @@ {% else %}
- {{ 'label.empty'|trans({}, 'EasyAdminBundle') }} + {{ include(entity_config.templates.label_empty) }}
{% endif %} {% else %} diff --git a/Resources/views/default/field_association.html.twig b/Resources/views/default/field_association.html.twig index a53500df19..e592e3265c 100644 --- a/Resources/views/default/field_association.html.twig +++ b/Resources/views/default/field_association.html.twig @@ -21,7 +21,7 @@ {% else %}
- {{ 'label.empty'|trans({}, 'EasyAdminBundle') }} + {{ include(entity_config.templates.label_empty) }}
{% endif %} {% elseif 'list' == view %} diff --git a/Resources/views/default/field_json_array.html.twig b/Resources/views/default/field_json_array.html.twig index 8d3c4270bb..be50a4c4bb 100644 --- a/Resources/views/default/field_json_array.html.twig +++ b/Resources/views/default/field_json_array.html.twig @@ -7,7 +7,7 @@ {% else %}
- {{ 'label.empty'|trans({}, 'EasyAdminBundle') }} + {{ include(entity_config.templates.label_empty) }}
{% endif %} {% else %} diff --git a/Resources/views/default/field_simple_array.html.twig b/Resources/views/default/field_simple_array.html.twig index 8d3c4270bb..be50a4c4bb 100644 --- a/Resources/views/default/field_simple_array.html.twig +++ b/Resources/views/default/field_simple_array.html.twig @@ -7,7 +7,7 @@ {% else %}
- {{ 'label.empty'|trans({}, 'EasyAdminBundle') }} + {{ include(entity_config.templates.label_empty) }}
{% endif %} {% else %} diff --git a/Resources/views/form/bootstrap_3_layout.html.twig b/Resources/views/form/bootstrap_3_layout.html.twig index 145a5ccd75..21138ba97b 100644 --- a/Resources/views/form/bootstrap_3_layout.html.twig +++ b/Resources/views/form/bootstrap_3_layout.html.twig @@ -353,7 +353,7 @@ {% block empty_collection %}
- {{ 'label.empty'|trans({}, 'EasyAdminBundle') }} + {{ include(easyadmin.entity.templates.label_empty) }}
{% endblock empty_collection %} diff --git a/Twig/EasyAdminTwigExtension.php b/Twig/EasyAdminTwigExtension.php index 47334c3114..cde2671759 100644 --- a/Twig/EasyAdminTwigExtension.php +++ b/Twig/EasyAdminTwigExtension.php @@ -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 { @@ -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) { diff --git a/UPGRADE.md b/UPGRADE.md index 9e8f532ef2..1ec1bce48b 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -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