diff --git a/core/includes/form.inc b/core/includes/form.inc index aea9af1faa5963346f9cb5adc333e7a11703a544..ae041444867886db373b00c2c6074274cb3cb77d 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -2822,6 +2822,9 @@ function theme_radios($variables) { if (!empty($element['#attributes']['class'])) { $attributes['class'] .= ' ' . implode(' ', $element['#attributes']['class']); } + if (isset($element['#attributes']['title'])) { + $attributes['title'] = $element['#attributes']['title']; + } return '<div' . drupal_attributes($attributes) . '>' . (!empty($element['#children']) ? $element['#children'] : '') . '</div>'; } @@ -3086,6 +3089,9 @@ function theme_checkboxes($variables) { if (!empty($element['#attributes']['class'])) { $attributes['class'] = array_merge($attributes['class'], $element['#attributes']['class']); } + if (isset($element['#attributes']['title'])) { + $attributes['title'] = $element['#attributes']['title']; + } return '<div' . drupal_attributes($attributes) . '>' . (!empty($element['#children']) ? $element['#children'] : '') . '</div>'; } @@ -3095,6 +3101,7 @@ function theme_checkboxes($variables) { * This is used as a pre render function for checkboxes and radios. */ function form_pre_render_conditional_form_element($element) { + $t = get_t(); // Set the element's title attribute to show #title as a tooltip, if needed. if (isset($element['#title']) && $element['#title_display'] == 'attribute') { $element['#attributes']['title'] = $element['#title']; diff --git a/core/modules/simpletest/tests/form.test b/core/modules/simpletest/tests/form.test index 49cab7bdb41a3751d7e0015106552abaee87635d..eed1287aa36d0f7a9ceda1d2a31b31151e54cabf 100644 --- a/core/modules/simpletest/tests/form.test +++ b/core/modules/simpletest/tests/form.test @@ -848,6 +848,12 @@ class FormsElementsLabelsTestCase extends DrupalWebTestCase { $elements = $this->xpath('//div[@id="form-test-textfield-title-suffix"]/preceding-sibling::div[contains(@class, \'form-item-form-textfield-test-title\')]'); $this->assertTrue(isset($elements[0]), t("Properly places the #suffix element before the form item.")); + + // Check title attribute for radios and checkboxes. + $elements = $this->xpath('//div[@id="edit-form-checkboxes-title-attribute"]'); + $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.'); } } diff --git a/core/modules/simpletest/tests/form_test.module b/core/modules/simpletest/tests/form_test.module index 321093864cde985b9312d3e4b6641d2df545467c..01908b9db5d66f58ad24b6a684cc543cbf5431d2 100644 --- a/core/modules/simpletest/tests/form_test.module +++ b/core/modules/simpletest/tests/form_test.module @@ -860,10 +860,31 @@ function form_label_test_form() { '#title' => t('Textfield test for invisible title'), '#title_display' => 'invisible', ); - // Textfield test for title set not to display + // Textfield test for title set not to display. $form['form_textfield_test_title_no_show'] = array( '#type' => 'textfield', ); + // Checkboxes & radios with title as attribute. + $form['form_checkboxes_title_attribute'] = array( + '#type' => 'checkboxes', + '#title' => 'Checkboxes test', + '#options' => array( + 'first-checkbox' => 'First checkbox', + 'second-checkbox' => 'Second checkbox', + ), + '#title_display' => 'attribute', + '#required' => TRUE, + ); + $form['form_radios_title_attribute'] = array( + '#type' => 'radios', + '#title' => 'Radios test', + '#options' => array( + 'first-radio' => 'First radio', + 'second-radio' => 'Second radio', + ), + '#title_display' => 'attribute', + '#required' => TRUE, + ); return $form; }