Add form functions for password, submit and reset.
[squirrelmail.git] / functions / forms.php
index 850d58b8d31546fbbfbcb40ec77ab40f8ce8d2fb..bf540d1dc87457e3c02f57098356b289e0170cd4 100644 (file)
  * Helper function to create form fields, not to be called directly,
  * only by other functions below.
  */
-function addInputField($type, $name, $value, $attributes = '') {
-    return '<input type="'.$type.'" name="'.htmlentities($name).'" '.
-        ' value="'.htmlentities($value).'"'.
+function addInputField($type, $name = null, $value = null, $attributes = '') {
+    return '<input type="'.$type.'"'.
+        ($name  !== null ? ' name="'.htmlentities($name).'"'   : '').
+        ($value !== null ? ' value="'.htmlentities($value).'"' : '').
         $attributes . ">\n";
 }
 
+/**
+ * Password input field
+ */
+function addPwField($name) {
+    return addInputField('password', $name);
+}
+
 
 /**
  * Form checkbox
@@ -93,6 +101,20 @@ function addSelect($name, $values, $default = null, $usekeys = false)
     return $ret;
 }
 
+/**
+ * Form submission button
+ * Note the switched value/name parameters!
+ */
+function addSubmit($value, $name = null) {
+    return addInputField('submit', $name, $value);
+}
+/**
+ * Form reset button, $value = caption
+ */
+function addReset($value) {
+    return addInputField('reset', null, $value);
+}
+
 /**
  * Textarea form element.
  */