Skip to content
Snippets Groups Projects
Commit a24ec590 authored by Jared Hancock's avatar Jared Hancock
Browse files

forms: Phone numbers with no digits = invalid

Previously, the characters would be removed and the data would be considered
empty which would bypass validation and clear the phone number on save
rather than triggering a validation error.
parent 3716087a
No related branches found
No related tags found
No related merge requests found
......@@ -662,7 +662,9 @@ class PhoneField extends FormField {
function parse($value) {
// NOTE: Value may have a legitimate 'X' to separate the number and
// extension parts. Don't remove the 'X'
return preg_replace('/[^\dX]/', '', $value);
$val = preg_replace('/[^\dX]/', '', $value);
// Pass completely-incorrect string for validation error
return $val ?: $value;
}
function toString($value) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment