Issue #2637680 by Dom., maximpodorov, Chris Burge, mikeocana, laranajim, jhodgdon, catch: Submit buttons for GET forms in search/views are not W3C valid due to empty "name" attribute
parent
597fbe5ee0
commit
2a225b29f6
|
@ -3924,6 +3924,11 @@ function theme_button($variables) {
|
|||
$element['#attributes']['type'] = 'submit';
|
||||
element_set_attributes($element, array('id', 'name', 'value'));
|
||||
|
||||
// Remove name attribute, if empty, for W3C compliance.
|
||||
if (isset($element['#attributes']['name']) && $element['#attributes']['name'] === '') {
|
||||
unset($element['#attributes']['name']);
|
||||
}
|
||||
|
||||
$element['#attributes']['class'][] = 'form-' . $element['#button_type'];
|
||||
if (!empty($element['#attributes']['disabled'])) {
|
||||
$element['#attributes']['class'][] = 'form-button-disabled';
|
||||
|
|
|
@ -852,6 +852,12 @@ class FormsElementsLabelsTestCase extends DrupalWebTestCase {
|
|||
$this->assertEqual($elements[0]['title'], 'Checkboxes test' . ' (' . t('Required') . ')', 'Title attribute found.');
|
||||
$elements = $this->xpath('//div[@id="edit-form-radios-title-attribute"]');
|
||||
$this->assertEqual($elements[0]['title'], 'Radios test' . ' (' . t('Required') . ')', 'Title attribute found.');
|
||||
|
||||
// Check that empty name attribute is not printed on buttons.
|
||||
$elements = $this->xpath('//input[@id="edit-form-button-with-name"]');
|
||||
$this->assertTrue($elements[0]['name'] == 'op', 'Name attribute found.');
|
||||
$elements = $this->xpath('//input[@id="edit-form-button-without-name"]');
|
||||
$this->assertFalse(isset($elements[0]['name']), 'No name attribute found.');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1022,6 +1022,16 @@ function form_label_test_form() {
|
|||
'#title_display' => 'attribute',
|
||||
'#required' => TRUE,
|
||||
);
|
||||
// Button elements with and without name attribute.
|
||||
$form['form_button_with_name'] = array(
|
||||
'#type' => 'button',
|
||||
'#value' => t('Button with name'),
|
||||
);
|
||||
$form['form_button_without_name'] = array(
|
||||
'#type' => 'button',
|
||||
'#value' => t('Button without name'),
|
||||
'#name' => '',
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue