Commit 78a76702 authored by alexpott's avatar alexpott

Issue #1419036 by lauriii, gnuget, wheatpenny, InternetDevels, oliverhm,...

Issue #1419036 by lauriii, gnuget, wheatpenny, InternetDevels, oliverhm, scresante, patrickd | sun: Added a CSS class for form items that have no label.
parent f531d9de
......@@ -2896,6 +2896,11 @@ function template_preprocess_form_element(&$variables) {
if (!isset($element['#title'])) {
$element['#title_display'] = 'none';
}
// If #title_dislay is not some of the visible options, add a CSS class.
if ($element['#title_display'] != 'before' && $element['#title_display'] != 'after') {
$variables['attributes']['class'][] = 'form-no-label';
}
$variables['prefix'] = isset($element['#field_prefix']) ? $element['#field_prefix'] : NULL;
$variables['suffix'] = isset($element['#field_suffix']) ? $element['#field_suffix'] : NULL;
......
......@@ -77,6 +77,9 @@ function testFormLabels() {
$elements = $this->xpath('//label[@for="edit-form-textfield-test-title-no-show"]');
$this->assertFalse(isset($elements[0]), 'No label tag when title set not to display.');
$elements = $this->xpath('//div[contains(@class, "form-item-form-textfield-test-title-invisible") and contains(@class, "form-no-label")]');
$this->assertTrue(isset($elements[0]), 'Field class is form-no-label when there is no label.');
// Check #field_prefix and #field_suffix placement.
$elements = $this->xpath('//span[@class="field-prefix"]/following-sibling::div[@id="edit-form-radios-test"]');
$this->assertTrue(isset($elements[0]), 'Properly placed the #field_prefix element after the label and before the field.');
......
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