From 7af2bad4e2b23839557756e8a413267e4a0c94ef Mon Sep 17 00:00:00 2001 From: Laurent David Date: Mon, 12 Sep 2022 08:24:55 +0200 Subject: [PATCH] MDL-75599 mod_data: Fix warning message * Fix warning message when accessing advanced search page with a date field. --- mod/data/field/date/field.class.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mod/data/field/date/field.class.php b/mod/data/field/date/field.class.php index c488f562cf9..e097e869bab 100644 --- a/mod/data/field/date/field.class.php +++ b/mod/data/field/date/field.class.php @@ -72,12 +72,20 @@ class data_field_date extends data_field_base { return $str; } - //Enable the following three functions once core API issues have been addressed. - function display_search_field($value=0) { - $selectors = html_writer::select_time('days', 'f_'.$this->field->id.'_d', $value['timestamp']) - . html_writer::select_time('months', 'f_'.$this->field->id.'_m', $value['timestamp']) - . html_writer::select_time('years', 'f_'.$this->field->id.'_y', $value['timestamp']); - $datecheck = html_writer::checkbox('f_'.$this->field->id.'_z', 1, $value['usedate']); + // Enable the following three functions once core API issues have been addressed. + + /** + * Display the search field in advanced search page + * @param mixed $value + * @return string + * @throws coding_exception + */ + public function display_search_field($value = null) { + $currenttime = time(); + $selectors = html_writer::select_time('days', 'f_' . $this->field->id . '_d', $value['timestamp'] ?? $currenttime) + . html_writer::select_time('months', 'f_' . $this->field->id . '_m', $value['timestamp'] ?? $currenttime) + . html_writer::select_time('years', 'f_' . $this->field->id . '_y', $value['timestamp'] ?? $currenttime); + $datecheck = html_writer::checkbox('f_' . $this->field->id . '_z', 1, $value['usedate'] ?? 0); $str = '
' . $selectors . ' ' . $datecheck . ' ' . get_string('usedate', 'data') . '
'; return $str;