Commit 154389da authored by David_Rothstein's avatar David_Rothstein

Issue #799356 by vijaycs85, m1n0, jaffaralia, effulgentsia: Fixed...

Issue #799356 by vijaycs85, m1n0, jaffaralia, effulgentsia: Fixed _form_set_class() is too aggressive in assigning the 'error' class.
parent 005708ce
......@@ -4167,7 +4167,7 @@ function _form_set_class(&$element, $class = array()) {
if (!empty($element['#required'])) {
$element['#attributes']['class'][] = 'required';
}
if (isset($element['#parents']) && form_get_error($element) !== NULL) {
if (isset($element['#parents']) && form_get_error($element) !== NULL && !empty($element['#validated'])) {
$element['#attributes']['class'][] = 'error';
}
}
......
......@@ -657,6 +657,17 @@ class FormValidationTestCase extends DrupalWebTestCase {
$this->assertText(t('!name field is required.', array('!name' => 'Title')));
$this->assertText('Test element is invalid');
}
/**
* Tests error border of multiple fields with same name in a page.
*/
function testMultiFormSameNameErrorClass() {
$this->drupalGet('form-test/double-form');
$edit = array();
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertFieldByXpath('//input[@id="edit-name" and contains(@class, "error")]', NULL, 'Error input form element class found for first element.');
$this->assertNoFieldByXpath('//input[@id="edit-name--2" and contains(@class, "error")]', NULL, 'No error input form element class found for second element.');
}
}
/**
......
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