Fixing issue in FormHelper::select() with $options array numeric keys being reset

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3394 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2006-08-10 17:05:59 +00:00
parent 9c75c34b62
commit 02ed400c61

View file

@ -243,11 +243,14 @@ class FormHelper extends Helper {
}
if ($showEmpty !== null && $showEmpty !== false) {
array_unshift($options, array('name' => $showEmpty, 'value' => ''));
$keys = array_keys($options);
$vals = array_values($options);
array_unshift($keys, '');
array_unshift($vals, $showEmpty);
$options = array_combine($keys, $vals);
}
$select = am($select, $this->selectOptions($options, $selected));
$select[] = sprintf($this->tags['selectend']);
return $this->output(implode("\n", $select));
}
@ -279,6 +282,7 @@ class FormHelper extends Helper {
}
if ($name !== null) {
pr($name);
if (($selected !== null) && ($selected == $name)) {
$htmlOptions['selected'] = 'selected';
} else if(is_array($selected) && in_array($name, $selected)) {