浏览代码

Add form functions for password, submit and reset.

Thijs Kinkhorst 21 年之前
父节点
当前提交
14cc9f11af
共有 1 个文件被更改,包括 25 次插入3 次删除
  1. 25 3
      functions/forms.php

+ 25 - 3
functions/forms.php

@@ -16,12 +16,20 @@
  * 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.
  */