Browse Source

Avoid exception is the template is not defined

Thomas Rabaix 13 năm trước cách đây
mục cha
commit
7ccb9f407d
1 tập tin đã thay đổi với 3 bổ sung1 xóa
  1. 3 1
      Twig/Extension/SonataAdminExtension.php

+ 3 - 1
Twig/Extension/SonataAdminExtension.php

@@ -72,8 +72,10 @@ class SonataAdminExtension extends \Twig_Extension
     protected function getTemplate(FieldDescriptionInterface $fieldDescription, $default)
     {
         // todo: find a better solution
+        $templateName = $fieldDescription->getTemplate() ?: $default;
+
         try {
-            $template = $this->environment->loadTemplate($fieldDescription->getTemplate());
+            $template = $this->environment->loadTemplate($templateName);
         } catch(\Twig_Error_Loader $e) {
             $template = $this->environment->loadTemplate($default);
         }