Browse Source

Add validation rule for session days if they are empty when creating multiple sessions

MOODLE_26_STABLE
Tim Lock 11 years ago
parent
commit
a10d92e882
  1. 6
      add_form.php
  2. 1
      lang/en/attendance.php

6
add_form.php

@ -161,6 +161,12 @@ class mod_attendance_add_form extends moodleform {
if ($data['sessiontype'] == attendance::SESSION_GROUP and empty($data['groups'])) {
$errors['groups'] = get_string('errorgroupsnotselected', 'attendance');
}
$addmulti = isset($data['addmultiply'])? (int)$data['addmultiply'] : 0;
if (($addmulti != 0) && (!array_key_exists('sdays',$data) || empty($data['sdays']))) {
$data['sdays']= array();
$errors['sdays'] = get_string('required', 'attendance');
}
return $errors;
}

1
lang/en/attendance.php

@ -153,6 +153,7 @@ $string['pluginname'] = 'Attendance';
$string['pluginadministration'] = 'Attendance administration';
$string['remarks'] = 'Remarks';
$string['report'] = 'Report';
$string['required'] = 'Required*';
$string['resetdescription'] = 'Remember that deleting attendance data will erase information from database. You can just hide older sessions having changed start date of course!';
$string['resetstatuses'] = 'Reset statuses to default';
$string['restoredefaults'] = 'Restore defaults';

Loading…
Cancel
Save