MDL-75599 mod_data: Fix warning message

* Fix warning message when accessing advanced search page with a date field.
This commit is contained in:
Laurent David 2022-09-12 08:24:55 +02:00
parent 3bc792b9b8
commit c85c8ebc6a

View file

@ -89,15 +89,20 @@ class data_field_date extends data_field_base {
return $str; return $str;
} }
//Enable the following three functions once core API issues have been addressed. // Enable the following three functions once core API issues have been addressed.
function display_search_field($value = null) {
if (empty($value)) { /**
$value = ['timestamp' => 0, 'usedate' => false]; * Display the search field in advanced search page
} * @param mixed $value
$selectors = html_writer::select_time('days', 'f_'.$this->field->id.'_d', $value['timestamp']) * @return string
. html_writer::select_time('months', 'f_'.$this->field->id.'_m', $value['timestamp']) * @throws coding_exception
. html_writer::select_time('years', 'f_'.$this->field->id.'_y', $value['timestamp']); */
$datecheck = html_writer::checkbox('f_'.$this->field->id.'_z', 1, $value['usedate']); 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 = '<div class="form-inline">' . $selectors . ' ' . $datecheck . ' ' . get_string('usedate', 'data') . '</div>'; $str = '<div class="form-inline">' . $selectors . ' ' . $datecheck . ' ' . get_string('usedate', 'data') . '</div>';
return $str; return $str;