Skip to content

Commit

Permalink
refactored diatomite field
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Sep 8, 2015
1 parent 661fe13 commit e1bbbd3
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions templates/forms/fields/datetime/datetime.html.twig
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 %}

0 comments on commit e1bbbd3

Please sign in to comment.