-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
13 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
{% extends "forms/field.html.twig" %} | ||
|
||
{% set default_php_dateformat = "d-m-Y H:i" %} | ||
{% set php_dateformat = config.system.pages.dateformat.default ?: default_php_dateformat %} | ||
{% set js_dateformat = admin.dateformat2Kendo(php_dateformat) %} | ||
{% set value = (value is null ? field.default : value) %} | ||
{% set value = (value is null ? value : value|date('d-m-Y H:i')) %} | ||
{% set value = (value is null ? value : value|date(php_dateformat)) %} | ||
|
||
{% block input %} | ||
<input | ||
type="text" | ||
data-grav-field-datetime | ||
class="{{ field.classes }}" | ||
name="{{ (scope ~ field.name)|fieldName }}" | ||
value="{{ value }}" | ||
{% if field.autofocus in ['on', 'true', 1] %}autofocus="autofocus"{% endif %} | ||
{% if field.novalidate in ['on', 'true', 1] %}novalidate="novalidate"{% endif %} | ||
{% if field.autocomplete in ['on', 'off'] %}autocomplete="{{ field.autocomplete }}"{% endif %} | ||
{% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %} | ||
{% if field.validate.min %}min="{{ (field.validate.min is null ? field.validate.min : field.validate.min|date("d-m-Y H:i")) }}"{% endif %} | ||
{% if field.validate.max %}max="{{ (field.validate.max is null ? field.validate.max : field.validate.max|date("d-m-Y H:i")) }}"{% endif %} | ||
/> | ||
|
||
{% block input_attributes %} | ||
type="text" | ||
data-grav-field-datetime | ||
data-date-formats="{{ {'format': js_dateformat} | json_encode | e('html_attr') }}" | ||
{% if field.validate.min %}min="{{ (field.validate.min is null ? field.validate.min : field.validate.min|date(php_dateformat)) }}"{% endif %} | ||
{% if field.validate.max %}max="{{ (field.validate.max is null ? field.validate.max : field.validate.max|date(php_dateformat)) }}"{% endif %} | ||
{{ parent() }} | ||
{% endblock %} | ||
|