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.

8.0.x
webchick 2013-11-14 12:37:16 -08:00
parent 7c5e7f60e5
commit f614976af5
2 changed files with 7 additions and 1 deletions

View File

@ -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),

View File

@ -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();