r1621: Merging r1620 from trunk

Robert Sesek [2008-04-22 19:34]
r1621: Merging r1620 from trunk
diff --git a/docs/changes.txt b/docs/changes.txt
index 19ea960..9ed3ca7 100644
--- a/docs/changes.txt
+++ b/docs/changes.txt
@@ -1,3 +1,7 @@
+1.2.3
+===============================
+- Fixed: Custom select field that is mandatory doesn't accept the first option as a valid entry (bug://report/121)
+
 1.2.2
 ===============================
 - Fixed: A "Call-time pass-by-reference has been deprecated" on search.php
diff --git a/includes/functions.php b/includes/functions.php
index da654bc..06441db 100755
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -392,6 +392,11 @@ function process_custom_fields(&$bugapi, &$msg, $errorbox = false, $searchMode =
 			$bugapi->set($fieldname, intval($inputdata["$fieldname"]));
 			continue;
 		}
+		else if ($field['type'] == 'select_single')
+		{
+			$temp = unserialize($field['selects']);
+			$inputdata[$fieldname] = $temp[intval($inputdata["$fieldname"])] . ''; // make it a string so isset() doesn't catch
+		}

 		// field data wasn't passed, so skip it
 		if (!isset($inputdata["$fieldname"]))
@@ -426,7 +431,7 @@ function process_custom_fields(&$bugapi, &$msg, $errorbox = false, $searchMode =
 			}
 			else
 			{
-				if ($inputdata["$fieldname"] == -1)
+				if (empty($inputdata["$fieldname"]))
 				{
 					if (!$searchMode)
 					{
@@ -435,8 +440,7 @@ function process_custom_fields(&$bugapi, &$msg, $errorbox = false, $searchMode =
 					continue;
 				}

-				$temp = unserialize($field['selects']);
-				$bugapi->set($fieldname, trim($temp[ intval($inputdata["$fieldname"]) ]));;
+				$bugapi->set($fieldname, trim($inputdata["$fieldname"]));
 			}
 		}
 	}