فهرست منبع

Handle separated date and time single_text widget from datetime

When you choose single_text for date and time fields from a datetime one,
you have to do a special case on twig rendering.
Sullivan SENECHAL 9 سال پیش
والد
کامیت
9ed59a1b8f
2فایلهای تغییر یافته به همراه19 افزوده شده و 2 حذف شده
  1. 3 0
      CHANGELOG.md
  2. 16 2
      Resources/views/Form/form_admin_fields.html.twig

+ 3 - 0
CHANGELOG.md

@@ -14,6 +14,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 - Deprecated `AdminHelper::camelize()`
 - Deprecated `Admin` class
 
+### Fixed
+- Fixed bad rendering on datetime field with `single_text` widget for date and time
+
 ## [3.0.0](https://github.com/sonata-project/SonataAdminBundle/compare/2.3.10...3.0.0) - 2016-05-08
 ### Added
 - Add missing Route constructor parameters to `RouteCollection:add` method

+ 16 - 2
Resources/views/Form/form_admin_fields.html.twig

@@ -289,8 +289,22 @@ file that was distributed with this source code.
         <div {{ block('widget_container_attributes') }}>
             {{ form_errors(form.date) }}
             {{ form_errors(form.time) }}
-            {{ form_widget(form.date, {'row': false, 'input_wrapper_class': 'col-sm-2'}) }}
-            {{ form_widget(form.time, {'row': false, 'input_wrapper_class': 'col-sm-2'}) }}
+
+            {% if form.date.vars.widget == 'single_text' %}
+                <div class="col-sm-2">
+                    {{ form_widget(form.date) }}
+                </div>
+            {% else %}
+                {{ form_widget(form.date, {'row': false, 'input_wrapper_class': 'col-sm-2'}) }}
+            {% endif %}
+
+            {% if form.time.vars.widget == 'single_text' %}
+                <div class="col-sm-2">
+                    {{ form_widget(form.time) }}
+                </div>
+            {% else %}
+                {{ form_widget(form.time, {'row': false, 'input_wrapper_class': 'col-sm-2'}) }}
+            {% endif %}
         </div>
     {% endif %}
 {% endspaceless %}