diff --git a/libraries/src/Form/Form.php b/libraries/src/Form/Form.php index e46b8420b2e5e..a25b7a0bdff10 100644 --- a/libraries/src/Form/Form.php +++ b/libraries/src/Form/Form.php @@ -2066,14 +2066,18 @@ protected function validateField(\SimpleXMLElement $element, $group = null, $val // Check if the field is required. $required = ((string) $element['required'] == 'true' || (string) $element['required'] == 'required'); - $disabled = ((string) $element['disabled'] == 'true' || (string) $element['disabled'] == 'disabled'); - $fieldExistsInRequestData = $input->exists((string) $element['name']) || $input->exists($group . '.' . (string) $element['name']); - - // If the field is disabled but it is passed in the request this is invalid as disabled fields are not added to the request - if ($disabled && $fieldExistsInRequestData) + if ($input) { - return new \RuntimeException(\JText::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', $element['name'])); + $disabled = ((string) $element['disabled'] == 'true' || (string) $element['disabled'] == 'disabled'); + + $fieldExistsInRequestData = $input->exists((string) $element['name']) || $input->exists($group . '.' . (string) $element['name']); + + // If the field is disabled but it is passed in the request this is invalid as disabled fields are not added to the request + if ($disabled && $fieldExistsInRequestData) + { + return new \RuntimeException(\JText::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', $element['name'])); + } } if ($required)