MDL-52831 users: Automatically strip whitespace from name fields
[moodle.git] / user / edit_form.php
index 721b538..3eb12c8 100644 (file)
@@ -99,6 +99,11 @@ class user_edit_form extends moodleform {
         $mform = $this->_form;
         $userid = $mform->getElementValue('id');
 
+        // Trim required name fields.
+        foreach (useredit_get_required_name_fields() as $field) {
+            $mform->applyFilter($field, 'trim');
+        }
+
         if ($user = $DB->get_record('user', array('id' => $userid))) {
 
             // Remove description.