Index: lib/weblib.php
===================================================================
--- lib/weblib.php	(revision 1674)
+++ lib/weblib.php	(working copy)
@@ -1081,14 +1081,21 @@
 
 }
 
-/** Display an standard html text field with an optional label
+/** Display an standard html text field.
  *
- * @param string  $name    The name of the text field
- * @param string  $value   The value of the text field
- * @param string  $label   The label to be showed near the text field
- * @param string  $alt     The info to be inserted in the alt tag
+ * @param string  $name       The name of the text field
+ * @param string  $value      The value of the text field
+ * @param string  $alt        The info to be inserted in the alt tag
+ * @param int     $size       The size of the text field
+ * @param int     $maxlength  The maximum length of text
+ * @param boolean $return     if false (the default) the the output is printed directly, If true, the
+ *                            generated HTML is returned as a string.
+ * @param boolean $disabled   if true, the text field is generated in a disabled state. Default, false.
+ * @param int $tabindex       if given, sets the tabindex attribute on the textfield element. Default none.
+ * @param string              $id value to use for the id attribute of the textfield element. If none is given,
+ *                            then a suitable one is constructed.
  */
-function print_textfield ($name, $value, $alt = '',$size=50,$maxlength=0, $return=false) {
+function print_textfield ($name, $value, $alt = '',$size=50,$maxlength=0, $return=false, $disabled=false, $tabindex=0, $id='') {
 
     static $idcounter = 0;
 
@@ -1104,9 +1111,24 @@
         $maxlength = ' maxlength="'.$maxlength.'" ';
     }
 
-    $htmlid = 'auto-tf'.sprintf('%04d', ++$idcounter);
+    $attributes = '';
+    if ($disabled) {
+        $attributes .= ' disabled="disabled"';
+    }
+
+    if ($tabindex) {
+        $attributes .= ' tabindex="'.$tabindex.'"';
+    }
+
+    if ($id === '') {
+        $htmlid = 'auto-tf'.sprintf('%04d', ++$idcounter);
+    } else {
+        // We trust there are no odd characters in a given id.
+        $htmlid = $id;
+    }
+
     $output  = '<span class="textfield '.$name."\">";
-    $output .= '<input name="'.$name.'" id="'.$htmlid.'" type="text" value="'.$value.'" size="'.$size.'" '.$maxlength.' alt="'.$alt.'" />';
+    $output .= '<input name="'.$name.'" id="'.$htmlid.'" type="text" value="'.$value.'" size="'.$size.'" '.$maxlength.' alt="'.$alt.'"'.$attributes.' />';
 
     $output .= '</span>'."\n";
 

