Issue #866292 by marcingy, ygerasimov, attiks, quicksketch: Fixed '0' not displayed as checkbox / radios options (nor as any element #title).

8.0.x
catch 2011-12-13 01:21:23 +09:00
parent 4bd96ab7cf
commit 8c47bfff7a
3 changed files with 11 additions and 1 deletions

View File

@ -4003,7 +4003,7 @@ function theme_form_element_label($variables) {
$t = get_t();
// If title and required marker are both empty, output no label.
if (empty($element['#title']) && empty($element['#required'])) {
if ((!isset($element['#title']) || $element['#title'] === '') && empty($element['#required'])) {
return '';
}

View File

@ -612,9 +612,17 @@ class FormsElementsLabelsTestCase extends DrupalWebTestCase {
$elements = $this->xpath('//input[@id="edit-form-checkboxes-test-third-checkbox"]/following-sibling::label[@for="edit-form-checkboxes-test-third-checkbox" and @class="option"]');
$this->assertTrue(isset($elements[0]), t("Label follows field and label option class correct for regular checkboxes."));
// Make sure the label is rendered for checkboxes.
$elements = $this->xpath('//input[@id="edit-form-checkboxes-test-0"]/following-sibling::label[@for="edit-form-checkboxes-test-0" and @class="option"]');
$this->assertTrue(isset($elements[0]), t("Label 0 found checkbox."));
$elements = $this->xpath('//input[@id="edit-form-radios-test-second-radio"]/following-sibling::label[@for="edit-form-radios-test-second-radio" and @class="option"]');
$this->assertTrue(isset($elements[0]), t("Label follows field and label option class correct for regular radios."));
// Make sure the label is rendered for radios.
$elements = $this->xpath('//input[@id="edit-form-radios-test-0"]/following-sibling::label[@for="edit-form-radios-test-0" and @class="option"]');
$this->assertTrue(isset($elements[0]), t("Label 0 found radios."));
// Exercise various defaults for checkboxes and modifications to ensure
// appropriate override and correct behaviour.
$elements = $this->xpath('//input[@id="edit-form-checkbox-test"]/following-sibling::label[@for="edit-form-checkbox-test" and @class="option"]');

View File

@ -702,6 +702,7 @@ function form_label_test_form() {
'first-checkbox' => t('First checkbox'),
'second-checkbox' => t('Second checkbox'),
'third-checkbox' => t('Third checkbox'),
'0' => t('0'),
),
);
$form['form_radios_test'] = array(
@ -711,6 +712,7 @@ function form_label_test_form() {
'first-radio' => t('First radio'),
'second-radio' => t('Second radio'),
'third-radio' => t('Third radio'),
'0' => t('0'),
),
// Test #field_prefix and #field_suffix placement.
'#field_prefix' => '<span id="form-test-radios-field-prefix">' . t('Radios #field_prefix element') . '</span>',