Commit 5ab1bfcb authored by alexpott's avatar alexpott

Issue #2101427 by evilehk: Fixed Browser validation error with chrome on hidden required fields.

parent b3763793
......@@ -215,16 +215,24 @@ public function getFormOptions($database) {
'#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(
':input[name=driver]' => array('value' => $this->pdoDriver),
),
),
);
$form['username'] = array(
'#type' => 'textfield',
'#title' => t('Database username'),
'#default_value' => empty($database['username']) ? '' : $database['username'],
'#required' => TRUE,
'#size' => 45,
'#states' => array(
'required' => array(
':input[name=driver]' => array('value' => $this->pdoDriver),
),
),
);
$form['password'] = array(
......
......@@ -517,10 +517,10 @@ $(document).bind('state:disabled', function(e) {
$(document).bind('state:required', function(e) {
if (e.trigger) {
if (e.value) {
$(e.target).closest('.form-item, .form-wrapper').find('label').append('<abbr class="form-required" title="' + Drupal.t('This field is required.') + '">*</abbr>');
$(e.target).attr({ 'required': 'required', 'aria-required': 'aria-required' }).closest('.form-item, .form-wrapper').find('label').append(Drupal.theme('requiredMarker'));
}
else {
$(e.target).closest('.form-item, .form-wrapper').find('label .form-required').remove();
$(e.target).removeAttr('required aria-required').closest('.form-item, .form-wrapper').find('label .form-required').remove();
}
}
});
......@@ -566,4 +566,10 @@ function compare (a, b) {
return (a === b) ? (typeof a === 'undefined' ? a : true) : (typeof a === 'undefined' || typeof b === 'undefined');
}
$.extend(Drupal.theme, {
requiredMarker: function () {
return '<abbr class="form-required" title="' + Drupal.t('This field is required.') + '">*</abbr>';
}
});
})(jQuery);
......@@ -53,15 +53,22 @@ public function form(array $form, array &$form_state) {
'#submit' => array(array($this, 'submitForm')),
);
$custom_language_states_conditions = array(
'select#edit-predefined-langcode' => array('value' => 'custom'),
);
$form['custom_language'] = array(
'#type' => 'container',
'#states' => array(
'visible' => array(
'select#edit-predefined-langcode' => array('value' => 'custom'),
),
'visible' => $custom_language_states_conditions,
),
);
$this->commonForm($form['custom_language']);
$form['custom_language']['langcode']['#states'] = array(
'required' => $custom_language_states_conditions,
);
$form['custom_language']['name']['#states'] = array(
'required' => $custom_language_states_conditions,
);
$form['custom_language']['submit'] = array(
'#type' => 'submit',
'#value' => $this->t('Add custom language'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment