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 01:11:15 -0000 @@ -1494,6 +1494,25 @@ 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, #value, #options, #description, #extra, #multiple, + * #required, #name, #attributes, #size. + * @return + * A string " title=" and the element #title 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 @@ -1514,7 +1533,7 @@ function theme_select($element) { $size = $element['#size'] ? ' size="' . $element['#size'] . '"' : ''; _form_set_class($element, array('form-select')); $multiple = $element['#multiple']; - return ''; + return ''; } /** @@ -1656,13 +1675,11 @@ function theme_radio($element) { _form_set_class($element, array('form-radio')); $output = ''; - if (!is_null($element['#title'])) { - $output = ''; - } return $output; } @@ -1993,15 +2010,12 @@ function theme_checkbox($element) { $checkbox = ''; - if (!is_null($element['#title'])) { - $checkbox = ''; - } - return $checkbox; } @@ -2437,7 +2451,7 @@ function theme_textfield($element) { $output .= '' . $element['#field_prefix'] . ' '; } - $output .= ''; + $output .= ''; if (isset($element['#field_suffix'])) { $output .= ' ' . $element['#field_suffix'] . ''; @@ -2476,7 +2490,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 +2497,7 @@ function theme_textarea($element) { } _form_set_class($element, $class); - return ''; + return ''; } /** @@ -2518,9 +2531,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 +2566,7 @@ function form_process_weight($element) { */ function theme_file($element) { _form_set_class($element, array('form-file')); - return '\n"; + return '\n"; } /** @@ -2584,17 +2596,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/locale/locale.module =================================================================== RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v retrieving revision 1.258 diff -u -p -r1.258 locale.module --- modules/locale/locale.module 31 Aug 2009 17:06:09 -0000 1.258 +++ modules/locale/locale.module 1 Sep 2009 01:11:16 -0000 @@ -272,6 +272,7 @@ function locale_language_selector_form($ '#default_value' => $user_preferred_language->language, '#options' => $names, '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? t("This account's default language for e-mails, and preferred language for site presentation.") : t("This account's default language for e-mails."), + '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE, ); return $form; } @@ -301,6 +302,7 @@ function locale_form_node_type_form_alte '#default_value' => variable_get('language_content_type_' . $form['#node_type']->type, 0), '#options' => array(t('Disabled'), t('Enabled')), '#description' => t('Enable multilingual support for this content type. If enabled, a language selection field will be added to the editing form, allowing you to select from one of the enabled languages. If disabled, new posts are saved with the default language. Existing content will not be affected by changing this option.', array('!languages' => url('admin/config/regional/language'))), + '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE, ); } } Index: modules/node/content_types.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/content_types.inc,v retrieving revision 1.91 diff -u -p -r1.91 content_types.inc --- modules/node/content_types.inc 24 Aug 2009 19:26:46 -0000 1.91 +++ modules/node/content_types.inc 1 Sep 2009 01:11:16 -0000 @@ -155,7 +155,8 @@ function node_type_form(&$form_state, $t DRUPAL_OPTIONAL => t('Optional'), DRUPAL_REQUIRED => t('Required'), ), - ); + '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE, + ); $form['submission']['help'] = array( '#type' => 'textarea', '#title' => t('Explanation or submission guidelines'), @@ -179,6 +180,7 @@ function node_type_form(&$form_state, $t 'revision' => t('Create new revision'), ), '#description' => t('Users with the administer nodes permission will be able to override these options.'), + '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE, ); $form['display'] = array( '#type' => 'fieldset', Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.1117 diff -u -p -r1.1117 node.module --- modules/node/node.module 31 Aug 2009 17:06:09 -0000 1.1117 +++ modules/node/node.module 1 Sep 2009 01:11:17 -0000 @@ -2027,6 +2027,7 @@ function node_form_search_form_alter(&$f '#prefix' => '
', '#suffix' => '
', '#options' => $types, + '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE, ); $form['advanced']['submit'] = array( '#type' => 'submit', Index: modules/profile/profile.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/profile/profile.admin.inc,v retrieving revision 1.29 diff -u -p -r1.29 profile.admin.inc --- modules/profile/profile.admin.inc 22 Aug 2009 14:34:21 -0000 1.29 +++ modules/profile/profile.admin.inc 1 Sep 2009 01:11:17 -0000 @@ -252,6 +252,7 @@ Unless you know what you are doing, it i '#title' => t('Visibility'), '#default_value' => isset($edit['visibility']) ? $edit['visibility'] : PROFILE_PUBLIC, '#options' => array(PROFILE_HIDDEN => t('Hidden profile field, only accessible by administrators, modules and themes.'), PROFILE_PRIVATE => t('Private field, content only available to privileged users.'), PROFILE_PUBLIC => t('Public field, content shown on profile page but not used on member list pages.'), PROFILE_PUBLIC_LISTINGS => t('Public field, content shown on profile page and on member list pages.')), + '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE, ); if ($type == 'selection' || $type == 'list' || $type == 'textfield') { $form['fields']['page'] = array('#type' => 'textfield', Index: modules/profile/profile.module =================================================================== RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v retrieving revision 1.273 diff -u -p -r1.273 profile.module --- modules/profile/profile.module 31 Aug 2009 17:06:09 -0000 1.273 +++ modules/profile/profile.module 1 Sep 2009 01:11:18 -0000 @@ -158,6 +158,7 @@ function profile_block_configure($delta '#default_value' => variable_get('profile_block_author_fields', array()), '#options' => $fields, '#description' => t('Select which profile fields you wish to display in the block. Only fields designated as public in the profile field configuration are available.', array('@profile-admin' => url('admin/config/people/profile'))), + '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE, ); return $form; } @@ -447,6 +448,7 @@ function profile_form_profile($edit, $ac '#default_value' => isset($edit[$field->name]) ? $edit[$field->name] : '', '#description' => _profile_form_explanation($field), '#required' => $field->required, + '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE, ); break; } Index: modules/simpletest/tests/form_test.module =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/form_test.module,v retrieving revision 1.8 diff -u -p -r1.8 form_test.module --- modules/simpletest/tests/form_test.module 17 Aug 2009 07:12:16 -0000 1.8 +++ modules/simpletest/tests/form_test.module 1 Sep 2009 01:11:18 -0000 @@ -87,6 +87,7 @@ function form_test_test_form(&$form_stat '#type' => 'item', '#title' => 'Test Textfield', '#markup' => form_clean_id('form_test_form_clean_id_presence'), + '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE, ); return $form; } 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 01:11:18 -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.783 diff -u -p -r1.783 system.module --- modules/system/system.module 31 Aug 2009 17:06:10 -0000 1.783 +++ modules/system/system.module 1 Sep 2009 01:11:19 -0000 @@ -88,6 +88,25 @@ 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(). */ function system_help($path, $arg) { @@ -341,6 +360,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 +370,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 +388,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( @@ -381,7 +404,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( @@ -398,7 +421,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 +431,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( @@ -430,6 +454,7 @@ function system_elements() { '#size' => 60, '#theme' => 'file', '#theme_wrappers' => array('form_element'), + '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE, ); $type['tableselect'] = array( Index: modules/taxonomy/taxonomy.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.admin.inc,v retrieving revision 1.67 diff -u -p -r1.67 taxonomy.admin.inc --- modules/taxonomy/taxonomy.admin.inc 31 Aug 2009 20:44:22 -0000 1.67 +++ modules/taxonomy/taxonomy.admin.inc 1 Sep 2009 01:11:20 -0000 @@ -170,6 +170,7 @@ function taxonomy_form_vocabulary(&$form '#title' => t('Apply to content types'), '#default_value' => $edit['nodes'], '#options' => array_map('check_plain', node_type_get_names()), + '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE, ); $form['settings'] = array( '#type' => 'fieldset', Index: modules/user/user.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.admin.inc,v retrieving revision 1.76 diff -u -p -r1.76 user.admin.inc --- modules/user/user.admin.inc 27 Aug 2009 20:25:28 -0000 1.76 +++ modules/user/user.admin.inc 1 Sep 2009 01:11:20 -0000 @@ -285,7 +285,8 @@ function user_admin_settings() { t('Administrators only'), t('Visitors'), t('Visitors, but administrator approval is required'), - ) + ), + '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE, ); $form['registration_cancellation']['user_email_verification'] = array( '#type' => 'checkbox', Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.1037 diff -u -p -r1.1037 user.module --- modules/user/user.module 31 Aug 2009 17:06:10 -0000 1.1037 +++ modules/user/user.module 1 Sep 2009 01:11:22 -0000 @@ -1878,7 +1878,8 @@ function user_edit_form(&$form_state, $u '#type' => 'radios', '#title' => t('Status'), '#default_value' => isset($edit['status']) ? $edit['status'] : 1, - '#options' => array(t('Blocked'), t('Active')) + '#options' => array(t('Blocked'), t('Active')), + '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE, ); } if (user_access('administer permissions')) { @@ -1905,6 +1906,7 @@ function user_edit_form(&$form_state, $u '#default_value' => $default, '#options' => $roles, DRUPAL_AUTHENTICATED_RID => $checkbox_authenticated, + '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE, ); } }