MDL-72673 mod_glossary: Generate unique ID for Keywords select element

This commit is contained in:
Jun Pataleta 2021-09-24 16:36:58 +08:00
parent 214adb7984
commit 8c180760eb

View File

@ -1195,18 +1195,9 @@ function glossary_print_entry_aliases($course, $cm, $glossary, $entry,$mode='',
global $DB;
$return = '';
if ( $aliases = $DB->get_records('glossary_alias', array('entryid'=>$entry->id))) {
foreach ($aliases as $alias) {
if (trim($alias->alias)) {
if ($return == '') {
$return = '<select id="keyword" class="custom-select">';
}
$return .= "<option>$alias->alias</option>";
}
}
if ($return != '') {
$return .= '</select>';
}
if ($aliases = $DB->get_fieldset_select('glossary_alias', 'alias', 'entryid = :entryid', ['entryid' => $entry->id])) {
$id = "keyword-{$entry->id}";
$return = html_writer::select($aliases, $id, '', false, ['id' => $id]);
}
if ($type == 'print') {
echo $return;
@ -1376,9 +1367,10 @@ function glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $m
if ($aliases || $icons || !empty($entry->rating)) {
echo '<table>';
if ( $aliases ) {
$id = "keyword-{$entry->id}";
echo '<tr valign="top"><td class="aliases">' .
'<label for="keyword">' . get_string('aliases','glossary').': </label>' .
$aliases . '</td></tr>';
'<label for="' . $id . '">' . get_string('aliases', 'glossary') . ': </label>' .
$aliases . '</td></tr>';
}
if ($icons) {
echo '<tr valign="top"><td class="icons">'.$icons.'</td></tr>';