Prechádzať zdrojové kódy

Merge pull request #527 from bshaffer/fixes_date_and_datetime_rendering_in_crud_show_templates

NULL date and datetimes no longer render as current date/datetime in CRUD show templates
Thomas 13 rokov pred
rodič
commit
75fa4a5982

+ 7 - 1
Resources/views/CRUD/show_date.html.twig

@@ -11,4 +11,10 @@ file that was distributed with this source code.
 
 {% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %}
 
-{% block field %}{{ value|date('F j, Y') }}{% endblock %}
+{% block field%}
+    {%- if value is empty -%}
+         
+    {%- else -%}
+        {{ value|date('F j, Y') }}
+    {%- endif -%}
+{% endblock %}

+ 7 - 1
Resources/views/CRUD/show_datetime.html.twig

@@ -11,5 +11,11 @@ file that was distributed with this source code.
 
 {% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %}
 
-{% block field %}{{ value|date }}{% endblock %}
+{% block field %}
+    {%- if value is empty -%}
+         
+    {%- else -%}
+        {{ value|date }}
+    {%- endif -%}
+{% endblock %}