Permalink
Browse files

improve checks against default values

  • Loading branch information...
1 parent 67ea231 commit 0671fcc6c9a3529b8feb07ff318784ba4106056c @haraldpdl haraldpdl committed Nov 6, 2011
Showing with 3 additions and 3 deletions.
  1. +3 −3 osCommerce/OM/Core/HTML.php
@@ -412,7 +412,7 @@ public static function selectMenu($name, $values, $default = null, $parameters =
$field .= '<option value="' . static::output($values[$i]['id']) . '"';
- if ( (!is_null($default) && !is_array($default) && ((string)$default == (string)$values[$i]['id'])) || (is_array($default) && in_array($values[$i]['id'], $default)) ) {
+ if ( isset($default) && ((!is_array($default) && ((string)$default == (string)$values[$i]['id'])) || (is_array($default) && in_array($values[$i]['id'], $default))) ) {
$field .= ' selected="selected"';
}
@@ -492,11 +492,11 @@ protected static function selectionField($name, $type, $values, $default = null,
$field .= ' id="' . static::output(substr($parameters, $offset+4, strpos($parameters, '"', $offset+4)-($offset+4))) . '_' . $counter . '"';
}
- if ( !empty($selection_value) ) {
+ if ( !is_null($selection_value) ) {
$field .= ' value="' . static::output($selection_value) . '"';
}
- if ( (is_bool($default) && $default === true) || ((is_string($default) && (trim($default) == trim($selection_value))) || (is_array($default) && in_array(trim($selection_value), $default))) ) {
+ if ( isset($default) && (($default === true) || (!is_array($default) && ((string)$default == (string)$selection_value)) || (is_array($default) && in_array($selection_value, $default))) ) {
$field .= ' checked="checked"';
}

0 comments on commit 0671fcc

Please sign in to comment.