phpMyEdit - Viewing Bug Advanced Details [ Go Back ]
446 core / field option feature always 2007-07-04 23:30 2007-09-08 13:45
nepto  
nepto  
normal  
feedback current from CVS  
reopened  
none  
none  
default value in pull-down not working
at least when there is lookup to another table...

fetched value is string, that's ok, but fetched key is integer...

So this re-typing is causing problems:

if ((! $found || $multiple) && in_array((string) $key, $selected, 1)
|| (count($selected) == 0 && ! $found && ! $multiple)) {
$ret .= ' selected="selected"';
$found = true;
}

Note that "(string)" in code above.
$opts['fdd']['location_id'] = array(
'name' => 'Location',
'sort' => true,
'values2' => array('' => '- select location -'),
'values' => array(
'table' => 'gastro_locations',
'column' => 'location_id',
'description' => 'name'),
);
if ($_REQUEST['location_id'] > 0) {
$opts['fdd']['location_id']['options'] = 'ACPVDLFR';
$opts['fdd']['location_id']['default'] = $_REQUEST['location_id'];
}

Bug Notes
nepto   
2007-07-04 23:43   
Fixed in CVS.
michal   
2007-09-08 13:45   
not fixed,

current cvs version php5 mysql50 both integers,
in add mode:
if 'default'=>'2' works
if 'default'=>2 does not work

fix code:
if (! is_array($selected)) {
$selected = $selected === null ? array() : array((string)$selected);
} else {
foreach($selected as $val) $selecte2[]=(string)$val;
$selected = $selected2;
}



and of course

if ((! $found || $multiple) && in_array((string)$key, $selected, 1)