- πΊπΈUnited States mikemccaffrey
I don't think the solution is to pass the value as is if it is wrong, since we do actually need to deal with the fact that the IP address is not a properly formatted range (or if someone had the gall to try to enter a range using asterisks).
The validateIpAddressElement function in IpAddressWidgetBase.php actually depends on there being an exception to validate the form field:
// Instantiate our IP, will throw \Exception if invalid. try { $ip_address = new IpAddress($value); } catch (\Exception $e) { // Make error messages a bit more relevant. if ($settings['allow_range']) { $form_state->setError($element, t('Invalid IP or range.')); } else { $form_state->setError($element, t('Invalid IP.')); } return; }
The question is why the IpAddress function isn't being constructed within that try catch in the validation function on form submission.
- πΊπΈUnited States kelly.m.jacobs
As an alternative solution, this patch will change it so we only run the massageFormValues logic if the form has passed validation.