Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.368
diff -u -p -r1.368 form.inc
--- includes/form.inc 29 Aug 2009 16:30:14 -0000 1.368
+++ includes/form.inc 1 Sep 2009 18:33:49 -0000
@@ -1494,6 +1494,24 @@ function form_options_flatten($array, $r
}
/**
+ * Return an attribute string if a form element's title should be output
+ * as a title attribute.
+ *
+ * @param $element
+ * An associative array containing the properties of the element.
+ * Properties used: #title, #show_title.
+ * @return
+ * A string " title=" containing the #title value if #show_title is set to
+ * FORM_ELEMENT_SHOW_TITLE_ATTRIBUTE, otherwise an empty string.
+ */
+function form_element_title_attribute($element) {
+ if (!empty($element['#title']) && isset($element['#show_title']) && $element['#show_title'] == FORM_ELEMENT_SHOW_TITLE_ATTRIBUTE) {
+ return ' title="' . $element['#title'] . '"';
+ }
+ return '';
+}
+
+/**
* Theme select form element.
*
* @param $element
@@ -1510,11 +1528,17 @@ function form_options_flatten($array, $r
* values are associative arrays in the normal $options format.
*/
function theme_select($element) {
- $select = '';
$size = $element['#size'] ? ' size="' . $element['#size'] . '"' : '';
_form_set_class($element, array('form-select'));
$multiple = $element['#multiple'];
- return '';
+ $select = '';
+ return $select;
}
/**
@@ -1656,13 +1680,11 @@ function theme_radio($element) {
_form_set_class($element, array('form-radio'));
$output = '';
- if (!is_null($element['#title'])) {
- $output = '';
- }
return $output;
}
@@ -1993,15 +2015,12 @@ function theme_checkbox($element) {
$checkbox = '';
- if (!is_null($element['#title'])) {
- $checkbox = '';
- }
-
return $checkbox;
}
@@ -2437,7 +2456,7 @@ function theme_textfield($element) {
$output .= '' . $element['#field_prefix'] . ' ';
}
- $output .= '';
+ $output .= '';
if (isset($element['#field_suffix'])) {
$output .= ' ' . $element['#field_suffix'] . '';
@@ -2476,7 +2495,6 @@ function theme_form($element) {
*/
function theme_textarea($element) {
$class = array('form-textarea');
-
// Add resizable behavior
if ($element['#resizable'] !== FALSE) {
drupal_add_js('misc/textarea.js');
@@ -2484,7 +2502,12 @@ function theme_textarea($element) {
}
_form_set_class($element, $class);
- return '';
+ $output = '';
+ return $output;
}
/**
@@ -2518,9 +2541,8 @@ function theme_markup($element) {
function theme_password($element) {
$size = $element['#size'] ? ' size="' . $element['#size'] . '" ' : '';
$maxlength = $element['#maxlength'] ? ' maxlength="' . $element['#maxlength'] . '" ' : '';
-
_form_set_class($element, array('form-text'));
- $output = '';
+ $output = '';
return $output;
}
@@ -2554,7 +2576,7 @@ function form_process_weight($element) {
*/
function theme_file($element) {
_form_set_class($element, array('form-file'));
- return '\n";
+ return '\n";
}
/**
@@ -2584,17 +2606,31 @@ function theme_form_element($element) {
$output = '
' . "\n";
$required = !empty($element['#required']) ? '
*' : '';
- if (!empty($element['#title']) && empty($element['#form_element_skip_title'])) {
+ $label = '';
+
+ if (!empty($element['#title'])) {
$title = $element['#title'];
if (!empty($element['#id'])) {
- $output .= '
\n";
+ $label = '
\n";
}
else {
- $output .= '
\n";
+ $label= '
\n";
}
}
- $output .= " " . $element['#children'] . "\n";
+ if ($element['#type'] == 'item') {
+ $output .= '
' . $element['#title'] . '
';
+ }
+
+ if (isset($element['#show_title']) && $element['#show_title'] == FORM_ELEMENT_SHOW_TITLE_BEFORE) {
+ $output .= $label . ' ' . $element['#children'] . "\n";
+ }
+ else if (isset($element['#show_title']) && $element['#show_title'] == FORM_ELEMENT_SHOW_TITLE_AFTER) {
+ $output .= $element['#children'] . ' ' . $label . "\n";
+ }
+ else {
+ $output .= ' ' . $element['#children'] . "\n";
+ }
if (!empty($element['#description'])) {
$output .= '
' . $element['#description'] . "
\n";
Index: modules/system/system.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.css,v
retrieving revision 1.61
diff -u -p -r1.61 system.css
--- modules/system/system.css 24 Aug 2009 03:11:34 -0000 1.61
+++ modules/system/system.css 1 Sep 2009 18:33:50 -0000
@@ -139,7 +139,9 @@ tr.merge-up, tr.merge-up td, tr.merge-up
display: block;
font-weight: bold;
}
-.form-item label.option {
+.form-item label.option,
+.form-type-checkbox label,
+.form-type-radio label {
display: inline;
font-weight: normal;
}
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.784
diff -u -p -r1.784 system.module
--- modules/system/system.module 1 Sep 2009 16:50:12 -0000 1.784
+++ modules/system/system.module 1 Sep 2009 18:33:52 -0000
@@ -86,6 +86,27 @@ define('REGIONS_VISIBLE', 'visible');
*/
define('REGIONS_ALL', 'all');
+/**
+ *
+ * Output form element titles as labels before form elements.
+ * @see system_elements().
+ */
+define('FORM_ELEMENT_SHOW_TITLE_BEFORE', 'before');
+
+/**
+ *
+ * Output form element titles as labels after form elements.
+ * @see system_elements().
+ */
+define('FORM_ELEMENT_SHOW_TITLE_AFTER', 'after');
+
+/**
+ *
+ * Output form element titles as the title attribute of form elements.
+ * @see system_elements().
+ */
+define('FORM_ELEMENT_SHOW_TITLE_ATTRIBUTE', 'attribute');
+
/**
* Implement hook_help().
@@ -341,6 +362,7 @@ function system_elements() {
'#process' => array('form_process_text_format', 'ajax_process_form'),
'#theme' => 'textfield',
'#theme_wrappers' => array('form_element'),
+ '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
);
$type['password'] = array(
@@ -350,12 +372,14 @@ function system_elements() {
'#process' => array('ajax_process_form'),
'#theme' => 'password',
'#theme_wrappers' => array('form_element'),
+ '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
);
$type['password_confirm'] = array(
'#input' => TRUE,
'#process' => array('form_process_password_confirm'),
'#theme_wrappers' => array('form_element'),
+ '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
);
$type['textarea'] = array(
@@ -366,6 +390,7 @@ function system_elements() {
'#process' => array('form_process_text_format', 'ajax_process_form'),
'#theme' => 'textarea',
'#theme_wrappers' => array('form_element'),
+ '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
);
$type['radios'] = array(
@@ -373,6 +398,7 @@ function system_elements() {
'#process' => array('form_process_radios'),
'#theme_wrappers' => array('radios'),
'#pre_render' => array('form_pre_render_conditional_form_element'),
+ '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
);
$type['radio'] = array(
@@ -381,7 +407,7 @@ function system_elements() {
'#process' => array('ajax_process_form'),
'#theme' => 'radio',
'#theme_wrappers' => array('form_element'),
- '#form_element_skip_title' => TRUE,
+ '#show_title' => FORM_ELEMENT_SHOW_TITLE_AFTER,
);
$type['checkboxes'] = array(
@@ -390,6 +416,7 @@ function system_elements() {
'#process' => array('form_process_checkboxes'),
'#theme_wrappers' => array('checkboxes'),
'#pre_render' => array('form_pre_render_conditional_form_element'),
+ '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
);
$type['checkbox'] = array(
@@ -398,7 +425,7 @@ function system_elements() {
'#process' => array('ajax_process_form'),
'#theme' => 'checkbox',
'#theme_wrappers' => array('form_element'),
- '#form_element_skip_title' => TRUE,
+ '#show_title' => FORM_ELEMENT_SHOW_TITLE_AFTER,
);
$type['select'] = array(
@@ -408,6 +435,7 @@ function system_elements() {
'#process' => array('ajax_process_form'),
'#theme' => 'select',
'#theme_wrappers' => array('form_element'),
+ '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
);
$type['weight'] = array(
@@ -423,6 +451,7 @@ function system_elements() {
'#process' => array('form_process_date'),
'#theme' => 'date',
'#theme_wrappers' => array('form_element'),
+ '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
);
$type['file'] = array(
@@ -430,6 +459,7 @@ function system_elements() {
'#size' => 60,
'#theme' => 'file',
'#theme_wrappers' => array('form_element'),
+ '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
);
$type['tableselect'] = array(