Преглед на файлове

Why weren't tag IDs part of the parameters to these functions in the first place? Sigh. For now, just use the same as the name, which is OK except for radio buttons, which concatenate value onto the name.

pdontthink преди 20 години
родител
ревизия
289ae066b6
променени са 1 файла, в които са добавени 5 реда и са изтрити 3 реда
  1. 5 3
      functions/forms.php

+ 5 - 3
functions/forms.php

@@ -17,9 +17,11 @@
  * Helper function to create form fields, not to be called directly,
  * only by other functions below.
  */
-function addInputField($type, $name = null, $value = null, $attributes = '') {
+function addInputField($type, $name = null, $value = null, $attributes = '', $id = null) {
     return '<input type="'.$type.'"'.
         ($name  !== null ? ' name="'.htmlspecialchars($name).'"'   : '').
+        ($id  !== null ? ' id="'.htmlspecialchars($id).'"'   
+            : ($name  !== null ? ' id="'.htmlspecialchars($name).'"'   : '')).
         ($value !== null ? ' value="'.htmlspecialchars($value).'"' : '').
         $attributes . " />\n";
 }
@@ -45,7 +47,7 @@ function addCheckBox($name, $checked = false, $value = null) {
  */
 function addRadioBox($name, $checked = false, $value = null) {
     return addInputField('radio', $name, $value,
-        ($checked ? ' checked="checked"' : ''));
+        ($checked ? ' checked="checked"' : ''), $name . $value);
 }
 
 /**
@@ -144,4 +146,4 @@ function addForm($action, $method = 'post', $name = '', $enctype = '', $charset
         $enctype . $name . $charset . ">\n";
 }
 
-?>
+?>