Hello,
i'm running a fresh install of Moodle 3.5.2 (Build: 20180910) with WebHook 3.0.1 (Build: 2018061900) and the list of checked events is never saved.
After some debugging, it showed up that after calling $mform->get_data() (editservice.php:59) the resulting $data object either has an empty events property or no events at all, while inspecting $_POST shows that events checkboxes array are actually there.
It looks like there's a problem with the backslashes used as the keys for the events array.
As a quick and dirty fix, I tried replacing the backslashes with an arbitrary char sequence and got everything saved as expected.
Here's what I did (note that my code refers the the v3.0.0-stable branch)
file classes/service_form.php, changed
/* Formation of the list of elements */
foreach ($eventlist as $event) {
$events[$event["component"]][] =& $mform->createElement("checkbox", $event["eventname"], $event["eventname"]);
}
to
/* Formation of the list of elements */
foreach ($eventlist as $event) php
// replace backslashes with 'XXX'
$events[$event["component"]][] =& $mform->createElement("checkbox", str_replace("\\","XXX",$event["eventname"]), $event["eventname"]);
}
file classes/handler.php in the events method, changed
foreach ($callbacks as $callback) {
self::handler_callback($data, $callback);
}
to
foreach ($callbacks as $callback) {
// replace 'XXX' with the backslash
foreach ($callback->events as $k=>$v) {
$callback->events[str_replace("XXX","\\",$k)] = $v;
unset($callback->events[$k]);
}
self::handler_callback($data, $callback);
}
Are you experiencing a similar issue? Shall we think of a more reliable way to fix it?
Cheers!