From f614976af5bd66298964ca7a3faea19035e47b08 Mon Sep 17 00:00:00 2001 From: webchick Date: Thu, 14 Nov 2013 12:37:16 -0800 Subject: [PATCH] Issue #2101427 by David_Rothstein, evilehk, nod_: Follow-up: Browser validation error with Chrome on hidden required fields, even on forms that don't allow client-side validation. --- core/lib/Drupal/Core/Database/Install/Tasks.php | 2 ++ core/misc/states.js | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/lib/Drupal/Core/Database/Install/Tasks.php b/core/lib/Drupal/Core/Database/Install/Tasks.php index 04993bd0f1c..929dde86c6b 100644 --- a/core/lib/Drupal/Core/Database/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Install/Tasks.php @@ -215,6 +215,7 @@ abstract class Tasks { '#title' => t('Database name'), '#default_value' => empty($database['database']) ? '' : $database['database'], '#size' => 45, + '#required' => TRUE, '#description' => t('The name of the database your @drupal data will be stored in.', array('@drupal' => drupal_install_profile_distribution_name())), '#states' => array( 'required' => array( @@ -228,6 +229,7 @@ abstract class Tasks { '#title' => t('Database username'), '#default_value' => empty($database['username']) ? '' : $database['username'], '#size' => 45, + '#required' => TRUE, '#states' => array( 'required' => array( ':input[name=driver]' => array('value' => $this->pdoDriver), diff --git a/core/misc/states.js b/core/misc/states.js index 81f4fcf12e8..30a49dc5492 100644 --- a/core/misc/states.js +++ b/core/misc/states.js @@ -517,7 +517,11 @@ $(document).bind('state:disabled', function(e) { $(document).bind('state:required', function(e) { if (e.trigger) { if (e.value) { - $(e.target).attr({ 'required': 'required', 'aria-required': 'aria-required' }).closest('.form-item, .form-wrapper').find('label').append(Drupal.theme('requiredMarker')); + var $label = $(e.target).attr({ 'required': 'required', 'aria-required': 'aria-required' }).closest('.form-item, .form-wrapper').find('label'); + // Avoids duplicate required markers on initialization. + if (!$label.find('.form-required').length) { + $label.append(Drupal.theme('requiredMarker')); + } } else { $(e.target).removeAttr('required aria-required').closest('.form-item, .form-wrapper').find('label .form-required').remove();