Skip to content
Snippets Groups Projects
Commit 66c79ee7 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #117748 by pwolanin: made account creation work again.

parent 39f1a6be
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -664,10 +664,11 @@ function _form_validate($elements, &$form_state, $form_id = NULL) { ...@@ -664,10 +664,11 @@ function _form_validate($elements, &$form_state, $form_id = NULL) {
// Validate the current input. // Validate the current input.
if (!isset($elements['#validated']) || !$elements['#validated']) { if (!isset($elements['#validated']) || !$elements['#validated']) {
if (isset($elements['#needs_validation'])) { if (isset($elements['#needs_validation'])) {
// We only check for trimmed string length being zero. 0 might be // Make sure a value is passed when the field is required.
// a possible value with some field types, such as radio buttons, so // A simple call to empty() will not cut it here as some fields, like
// empty() is not usable here. // checkboxes, can return a valid value of '0'. Instead, check the
if ($elements['#required'] && strlen(trim($elements['#value'])) == 0) { // length if it's a string, and the item count if it's an array.
if ($elements['#required'] && (!count($elements['#value']) || (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0))) {
form_error($elements, $t('!name field is required.', array('!name' => $elements['#title']))); form_error($elements, $t('!name field is required.', array('!name' => $elements['#title'])));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment