-
Bug
-
Resolution: Fixed
-
Minor
-
3.9.5, 3.10.1, 3.10.2
-
MOODLE_310_STABLE, MOODLE_39_STABLE
-
MOODLE_310_STABLE, MOODLE_39_STABLE
-
MDL-71039-master -
Autocomplete element has option valuehtmlcallback that allows to evaluate the display values of pre-selected elements. It works fine normally.
However if the autocomplete element is part of a group, it is ignored.
The autocomplete element is used with the valuehtmlcallback three times in Moodle LMS and actually all of them are not even needed because these forms can never have preselected values.
Here is the example how to reproduce it. Apply the following patch to the Moodle LMS, go to any forum and select "Export" from the settings menu. You should see the name of the user preselected in "User" autocomplete element but instead you see id.
diff --git a/mod/forum/classes/form/export_form.php b/mod/forum/classes/form/export_form.php
|
index fb571f94263..a59a7bb9d6c 100644
|
--- a/mod/forum/classes/form/export_form.php
|
+++ b/mod/forum/classes/form/export_form.php
|
@@ -66,7 +66,9 @@ class export_form extends \moodleform {
|
return $OUTPUT->render_from_template('mod_forum/form-user-selector-suggestion', $useroptiondata);
|
}
|
];
|
- $mform->addElement('autocomplete', 'useridsselected', get_string('users'), [], $options);
|
+ $group = [];
|
+ $group[] = $mform->createElement('autocomplete', 'useridsselected', get_string('users'), [], $options);
|
+ $mform->addGroup($group, 'useridsselectedgroup', get_string('users'), '', false);
|
|
// Get the discussions on this forum.
|
$vaultfactory = \mod_forum\local\container::get_vault_factory();
|
diff --git a/mod/forum/export.php b/mod/forum/export.php
|
index 9aee3f18809..ba9d5170cc6 100644
|
--- a/mod/forum/export.php
|
+++ b/mod/forum/export.php
|
@@ -78,6 +78,7 @@ $context = $forum->get_context();
|
$form = new mod_forum\form\export_form($url->out(false), [
|
'forum' => $forum
|
]);
|
+$form->set_data(['useridsselected' => [$USER->id]]);
|
|
if ($form->is_cancelled()) {
|
redirect(new moodle_url('/mod/forum/view.php', ['id' => $cm->id]));
|
- has a non-specific relationship to
-
MDL-61028 core_search: Allow filtering search by user
- Closed