Skip to content
Browse files

MDL-27931 admin bulk user upload: convert city as required field. Cre…

…dit goes to Charles Fulton for supplying the patch.
  • Loading branch information...
1 parent 81f8e0f commit fd9672ac65068a16c7c0ce25013dadf48405dcec @rwijaya rwijaya committed
Showing with 9 additions and 4 deletions.
  1. +8 −0 admin/uploaduser.php
  2. +1 −4 admin/uploaduser_form.php
View
8 admin/uploaduser.php
@@ -915,6 +915,14 @@
$rowcols['status'][] = $stremailduplicate;
}
}
+
+ if (isset($rowcols['city'])) {
+ $rowcols['city'] = trim($rowcols['city']);
+ if (empty($rowcols['city'])) {
+ $rowcols['status'][] = get_string('fieldrequired', 'error', 'city');
+ }
+ }
+
$rowcols['status'] = implode('<br />', $rowcols['status']);
$data[] = $rowcols;
}
View
5 admin/uploaduser_form.php
@@ -264,6 +264,7 @@ function definition () {
} else {
$mform->setDefault('city', $CFG->defaultcity);
}
+ $mform->addRule('city', get_string('required'), 'required');
$mform->addElement('select', 'country', get_string('selectacountry'), get_string_manager()->get_list_of_countries());
if (empty($CFG->country)) {
@@ -408,10 +409,6 @@ function validation($data, $files) {
if (!in_array('email', $columns) and empty($data['email'])) {
$errors['email'] = get_string('requiredtemplate', 'admin');
}
-
- if (!in_array('city', $columns) and empty($data['city'])) {
- $errors['city'] = get_string('required');
- }
}
return $errors;

0 comments on commit fd9672a

Please sign in to comment.
Something went wrong with that request. Please try again.