เพิ่มตัวเลือกวันที่ jquery สำหรับหน้านั้นเป็นการพึ่งพา your_theme.libraries.yml
date-picker:
js:
script/site-datepicker.js : {}
dependencies:
- core/jquery
- core/jquery.ui.datepicker
เว็บไซต์ datepicker.js
Drupal.behaviors.customDatepicker = {
attach: function (context, settings) {
jQuery(function () {
jQuery("#datepicker").datepicker({
dateFormat: "dd-mm-yy",
altField: "input[data-drupal-selector=edit-created]",
altFormat: "yy/mm/dd 23:59:59"
});
});
}
};
views-exposed-form-- views-block-name .html.twig
{% if q is not empty %}
{#
This ensures that, if clean URLs are off, the 'q' is added first,
as a hidden form element, so that it shows up first in the POST URL.
#}
{{ q }}
{% endif %}
<input id="datepicker" type="text">
<input data-drupal-selector="edit-created" data-msg-maxlength="This field field has a maximum length of 128." name="created" size="30" maxlength="128" aria-invalid="false" type="hidden">
{{ form|without('created') }}