Skip to content

Commit 83d6ec9

Browse files
committed
Fixed date-range-picker widget value without time-picker
1 parent b26b17b commit 83d6ec9

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/Resources/views/form/bootstrap_4_layout.html.twig

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,23 @@
6464
{%- if value is not empty %}
6565
{% set dates = value|split(locale_separator|default(constant('EWZ\\SymfonyAdminBundle\\Form\\Type\\DateRangePickerType::DEFAULT_SEPARATOR'))) %}
6666

67-
{% set string = dates[0]|date(is_granted('ROLE_USER') ? app.user.dateFormat ~ ' ' ~ app.user.timeFormat : constant('EWZ\\SymfonyAdminBundle\\Model\\User::PHP_DATE_FORMAT_US') ~ ' ' ~ constant('EWZ\\SymfonyAdminBundle\\Model\\User::PHP_TIME_FORMAT_12HOURS')) %}
68-
{% if dates[1] and dates[1] != dates[0] %}
69-
{% set string = string
70-
~ locale_separator|default(constant('EWZ\\SymfonyAdminBundle\\Form\\Type\\DateRangePickerType::DEFAULT_SEPARATOR'))
71-
~ dates[1]|date(is_granted('ROLE_USER') ? app.user.dateFormat ~ ' ' ~ app.user.timeFormat : constant('EWZ\\SymfonyAdminBundle\\Model\\User::PHP_DATE_FORMAT_US') ~ ' ' ~ constant('EWZ\\SymfonyAdminBundle\\Model\\User::PHP_TIME_FORMAT_12HOURS'))
72-
%}
73-
{% endif %}
67+
{%- if time_picker|default(false) -%}
68+
{% set string = dates[0]|date(is_granted('ROLE_USER') ? app.user.dateFormat ~ ' ' ~ app.user.timeFormat : constant('EWZ\\SymfonyAdminBundle\\Model\\User::PHP_DATE_FORMAT_US') ~ ' ' ~ constant('EWZ\\SymfonyAdminBundle\\Model\\User::PHP_TIME_FORMAT_12HOURS')) %}
69+
{% if dates[1] and dates[1] != dates[0] %}
70+
{% set string = string
71+
~ locale_separator|default(constant('EWZ\\SymfonyAdminBundle\\Form\\Type\\DateRangePickerType::DEFAULT_SEPARATOR'))
72+
~ dates[1]|date(is_granted('ROLE_USER') ? app.user.dateFormat ~ ' ' ~ app.user.timeFormat : constant('EWZ\\SymfonyAdminBundle\\Model\\User::PHP_DATE_FORMAT_US') ~ ' ' ~ constant('EWZ\\SymfonyAdminBundle\\Model\\User::PHP_TIME_FORMAT_12HOURS'))
73+
%}
74+
{% endif %}
75+
{%- else -%}
76+
{% set string = dates[0]|date(is_granted('ROLE_USER') ? app.user.dateFormat : constant('EWZ\\SymfonyAdminBundle\\Model\\User::PHP_DATE_FORMAT_US')) %}
77+
{% if dates[1] and dates[1] != dates[0] %}
78+
{% set string = string
79+
~ locale_separator|default(constant('EWZ\\SymfonyAdminBundle\\Form\\Type\\DateRangePickerType::DEFAULT_SEPARATOR'))
80+
~ dates[1]|date(is_granted('ROLE_USER') ? app.user.dateFormat : constant('EWZ\\SymfonyAdminBundle\\Model\\User::PHP_DATE_FORMAT_US'))
81+
%}
82+
{% endif %}
83+
{%- endif -%}
7484

7585
value="{{ string }}"
7686
{% endif -%}

0 commit comments

Comments
 (0)