diff -u includes/form.inc includes/form.inc
--- includes/form.inc 1 Dec 2009 07:22:15 -0000
+++ includes/form.inc 1 Dec 2009 17:12:02 -0000
@@ -2851,14 +2851,14 @@
* where a visual label is not needed, such as a table of checkboxes where
* the row and column provide the context. The tooltip will include the
* title and required marker.
- * - none: Suppress output of any label or required marker. For example, this
- * is used by the password_confirm #type as set in system_element_info().
- * The password_confirm field creates children elements that have their own
- * labels and required markers, but the parent element should have neither.
- * Use this value carefully because a field with no label and no surrounding
- * context causes challenges for accessibility.
- * The label or attribute includes a required marker for required fields for
- * all cases except 'none'.
+ * The label or attribute includes a required marker for required fields.
+ *
+ * If the #title property is not set the label and any required marker will
+ * not be displayed. This is used by the password_confirm element #type.
+ * The password_confirm field creates children elements that have their own
+ * labels and required markers, but the parent element should have neither.
+ * Use this carefully because a field with no label and no surrounding context
+ * causes challenges for accessibility.
*
* @param $variables
* An associative array containing:
@@ -2884,6 +2884,11 @@
if (!empty($element['#name'])) {
$class[] = 'form-item-' . strtr($element['#name'], array(' ' => '-', '_' => '-', '[' => '-', ']' => ''));
}
+
+ // If #title is not present, we don't display any label or required marker
+ if (!isset($element['#title'])) {
+ $element['#title_display'] = 'none';
+ }
$output = '
' . "\n";
@@ -3246,7 +3251,7 @@
$batch =& batch_get();
drupal_theme_initialize();
-
+
if (isset($batch)) {
// Add process information
$process_info = array(
@@ -3261,7 +3266,7 @@
);
$batch += $process_info;
- // The batch is now completely built. Allow other modules to make changes to the
+ // The batch is now completely built. Allow other modules to make changes to the
// batch so that it is easier to reuse batch processes in other enviroments.
drupal_alter('batch', $batch);
diff -u modules/simpletest/tests/form_test.module modules/simpletest/tests/form_test.module
--- modules/simpletest/tests/form_test.module 1 Dec 2009 07:22:16 -0000
+++ modules/simpletest/tests/form_test.module 1 Dec 2009 17:12:02 -0000
@@ -515,7 +515,9 @@
);
$form['form_textfield_test_no_title_required'] = array(
'#type' => 'textfield',
- // No title.
+ // We use an empty title, since not setting #title supresses the label
+ // and required marker.
+ '#title' => '',
'#required' => TRUE,
);
$form['form_textfield_test_title'] = array(
@@ -528,10 +530,9 @@
'#title' => t('Textfield test for title after element'),
'#title_display' => 'after',
);
+ // Textfield test for title set not to display
$form['form_textfield_test_title_no_show'] = array(
'#type' => 'textfield',
- '#title' => t('Textfield test for title set not to display'),
- '#title_display' => 'none',
);
return $form;
diff -u modules/system/system.module modules/system/system.module
--- modules/system/system.module 1 Dec 2009 07:22:17 -0000
+++ modules/system/system.module 1 Dec 2009 17:12:02 -0000
@@ -368,9 +368,6 @@
'#input' => TRUE,
'#process' => array('form_process_password_confirm', 'user_form_process_password_confirm'),
'#theme_wrappers' => array('form_element'),
- // Do not output a title or required marker for password_confirm.
- // The children elements will output their own titles as usual.
- '#title_display' => 'none',
);
$types['textarea'] = array(
'#input' => TRUE,