From 234d5bef20e4172f3cd3ed6d6f5a7264e8ca947c Mon Sep 17 00:00:00 2001 From: Dries Buytaert <dries@buytaert.net> Date: Sat, 26 Aug 2006 09:56:17 +0000 Subject: [PATCH] - Patch #38454 by drumm, jaza, webchick, timnc et al: add field pre- and suffixes to textfields. --- includes/form.inc | 14 +++++++++++++- modules/upload/upload.module | 9 ++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/includes/form.inc b/includes/form.inc index 44954953d48a..9e63aa900935 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -1176,13 +1176,25 @@ function theme_textfield($element) { $size = $element['#size'] ? ' size="' . $element['#size'] . '"' : ''; $class = array('form-text'); $extra = ''; + $output = ''; + if ($element['#autocomplete_path']) { drupal_add_js('misc/autocomplete.js'); $class[] = 'form-autocomplete'; $extra = '<input class="autocomplete" type="hidden" id="'. $element['#id'] .'-autocomplete" value="'. check_url(url($element['#autocomplete_path'], NULL, NULL, TRUE)) .'" disabled="disabled" />'; } _form_set_class($element, $class); - $output = '<input type="text" maxlength="'. $element['#maxlength'] .'" name="'. $element['#name'] .'" id="'. $element['#id'] .'" '. $size .' value="'. check_plain($element['#value']) .'"'. drupal_attributes($element['#attributes']) .' />'; + + if (isset($element['#field_prefix'])) { + $output .= '<span class="field-prefix">'. $element['#field_prefix'] .'</span> '; + } + + $output .= '<input type="text" maxlength="'. $element['#maxlength'] .'" name="'. $element['#name'] .'" id="'. $element['#id'] .'" '. $size .' value="'. check_plain($element['#value']) .'"'. drupal_attributes($element['#attributes']) .' />'; + + if (isset($element['#field_suffix'])) { + $output .= ' <span class="field-suffix">'. $element['#field_suffix'] .'</span>'; + } + return theme('form_element', $element, $output). $extra; } diff --git a/modules/upload/upload.module b/modules/upload/upload.module index 83427e717973..6a2ffc7a38f5 100644 --- a/modules/upload/upload.module +++ b/modules/upload/upload.module @@ -182,7 +182,8 @@ function upload_admin_settings() { '#default_value' => variable_get('upload_max_resolution', 0), '#size' => 15, '#maxlength' => 10, - '#description' => t('The maximum allowed image size expressed as WIDTHxHEIGHT (e.g. 640x480). Set to 0 for no restriction.'), + '#description' => t('The maximum allowed image size (e.g. 640x480). Set to 0 for no restriction.'), + '#field_suffix' => t('<kbd>WIDTHxHEIGHT</kbd>') ); $form['settings_general']['upload_list_default'] = array( '#type' => 'select', @@ -205,7 +206,8 @@ function upload_admin_settings() { '#default_value' => $upload_uploadsize_default, '#size' => 5, '#maxlength' => 5, - '#description' => t('The default maximum file size a user can upload (in megabytes).'), + '#description' => t('The default maximum file size a user can upload.'), + '#field_suffix' => t('MB') ); $form['settings_general']['upload_usersize_default'] = array( '#type' => 'textfield', @@ -213,7 +215,8 @@ function upload_admin_settings() { '#default_value' => $upload_usersize_default, '#size' => 5, '#maxlength' => 5, - '#description' => t('The default maximum size of all files a user can have on the site (in megabytes).'), + '#description' => t('The default maximum size of all files a user can have on the site.'), + '#field_suffix' => t('MB') ); $form['upload_max_size'] = array('#value' => '<p>'. t('Your PHP settings limit the maximum file size per upload to %size MB.', array('%size' => file_upload_max_size())).'</p>'); -- GitLab