Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding sensitivity to an array with a null key

  • Loading branch information...
commit 531f0cd68a6460606bed9893ae0a0ada5d2b3dd7 1 parent 472cc2b
@spekary authored
Showing with 9 additions and 8 deletions.
  1. +9 −8 includes/qcodo/_core/qform/QListControl.class.php
View
17 includes/qcodo/_core/qform/QListControl.class.php
@@ -107,18 +107,19 @@ public function AddItems (array $mixItemArray, $mixSelectedValues = null, $strIt
foreach ($mixItemArray as $val=>$item) {
$blnSelected = false;
- if ($mixSelectedValues) {
- if (gettype($mixSelectedValues) == QType::ArrayType) {
- $blnSelected = in_array ($val, $mixSelectedValues);
- }
- else {
- $blnSelected = ($val == $mixSelectedValues);
- }
+ if ($val === '') {
+ $val = null; // these are equivalent when specified as a key of an array
+ }
+ if ($mixSelectedValues && is_array($mixSelectedValues)) {
+ $blnSelected = in_array ($val, $mixSelectedValues);
+ }
+ else {
+ $blnSelected = ($val === $mixSelectedValues); // differentiate between null and 0 values
}
$this->AddItem ($item, $val, $blnSelected, $strItemGroup, $strOverrideParameters);
};
}
-
+
// Gets the ListItem at a specific location in objItemsArray
public function GetItem($intIndex) {
try {
Please sign in to comment.
Something went wrong with that request. Please try again.