public function CourseObjectAccessGrade::optionsValidate in Course 3.x
Same name and namespace in other branches
- 8.3 src/Plugin/course/CourseObjectAccess/CourseObjectAccessGrade.php \Drupal\course\Plugin\course\CourseObjectAccess\CourseObjectAccessGrade::optionsValidate()
- 8.2 src/Plugin/course/CourseObjectAccess/CourseObjectAccessGrade.php \Drupal\course\Plugin\course\CourseObjectAccess\CourseObjectAccessGrade::optionsValidate()
File
- src/
Plugin/ course/ CourseObjectAccess/ CourseObjectAccessGrade.php, line 29
Class
- CourseObjectAccessGrade
- Plugin annotation @CourseObjectAccess( id = "grade", label = @Translation("Grade"), )
Namespace
Drupal\course\Plugin\course\CourseObjectAccessCode
public function optionsValidate($form, &$form_state) {
if (!empty($form_state['course_grade_range']['low']) || !empty($form_state['course_grade_range']['high'])) {
// If user filled out at least one.
if (is_numeric($form_state['course_grade_range']['low']) && is_numeric($form_state['course_grade_range']['high'])) {
// User filled out both.
if ($form_state['course_grade_range']['low'] > $form_state['course_grade_range']['high']) {
form_error($form['course_grade_range'], t('High range cannot be lower than the low range.'));
}
}
else {
// User did not fill out both.
form_error($form['course_grade_range'], t('You must enter a numeric value for both the low and high grade range.'));
}
}
}