Commit 1f9a36fa authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic
Browse files

Bug 1819555: show date in calendar fields

behatnotneeded

Change-Id: Idacabed02a4e1ef93678daa559def47213549999
parent 0133c034
......@@ -59,12 +59,12 @@ function pieform_element_calendar(Pieform $form, $element) {
// Build the HTML
$element['class'] .= " datetimepicker-input";
$result = '<span class="hasDatepickerwrapper"><input type="text"'
. $form->element_attributes($element)
. $form->element_attributes($element, array('id'))
. ' id="' . $id . '"'
. ' value="' . $value . '"'
. ' autocomplete="off"'
. ' data-toggle="datetimepicker" data-target="#' . $id . '"'
. 'aria-label="' . get_string('element.calendar.format.arialabel', 'pieforms') . '"
. ' aria-label="' . get_string('element.calendar.format.arialabel', 'pieforms') . '"
></span>';
$result .= '
<script>
......@@ -79,6 +79,10 @@ function pieform_element_calendar(Pieform $form, $element) {
format: "' . $options['dateFormat'] . '",';
}
$tooltips = json_encode(pieform_element_calendar_tooltip_lang_strings());
if ($value) {
$result .= '
date: moment("' . $value . '", "' . $options['dateFormat'] . '"),';
}
$result .= '
locale: "' . strstr(current_language(), '.', true) . '",
useCurrent: false,
......
......@@ -186,6 +186,17 @@ jQuery(function($) {
formchangemanager.setFormStateById('{{$formname}}', FORM_CHANGED);
}
});
// ugly fix for open issue in tempusdominus bootstrap lib not getting the value from html tag
// https://github.com/tempusdominus/bootstrap-4/issues/126
target.each(function() {
var value = $(this).attr('value');
$(this).datetimepicker({
format: "{{str(tag='pieform_calendar_dateformat' section='langconfig')|pieform_element_calendar_convert_dateformat}} {{str(tag='pieform_calendar_timeformat' section='langconfig')|pieform_element_calendar_convert_timeformat}}",
date: value
});
$(this).val(value);
});
}
function formatSelect2Results (data) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment