Skip to content

Commit

Permalink
MDL-70648 calendar: add form validation for category events
Browse files Browse the repository at this point in the history
  • Loading branch information
lameze committed Jan 20, 2021
1 parent c381757 commit b9e33cc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions calendar/classes/local/event/forms/create.php
Expand Up @@ -128,6 +128,7 @@ public function validation($data, $files) {
$eventtype = isset($data['eventtype']) ? $data['eventtype'] : null;
$coursekey = ($eventtype == 'group') ? 'groupcourseid' : 'courseid';
$courseid = (!empty($data[$coursekey])) ? $data[$coursekey] : null;
$categoryid = (!empty($data['categoryid'])) ? $data['categoryid'] : null;

$eventtypes = $this->_customdata['eventtypes'];
if (empty($eventtype) || !isset($eventtypes[$eventtype]) || $eventtypes[$eventtype] == false) {
Expand All @@ -148,6 +149,10 @@ public function validation($data, $files) {
$errors['courseid'] = get_string('selectacourse');
}

if ($eventtype == 'category' && empty($categoryid)) {
$errors['categoryid'] = get_string('selectacategory');
}

if ($eventtype == 'group' && (!empty($courseid) && empty($data['groupid']))) {
$errors['groupcourseid'] = get_string('nogroups', 'core_group');
}
Expand Down

0 comments on commit b9e33cc

Please sign in to comment.