From 02ed400c61d14e346a3db52d9c893156d99600d5 Mon Sep 17 00:00:00 2001 From: nate Date: Thu, 10 Aug 2006 17:05:59 +0000 Subject: [PATCH] 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 --- cake/libs/view/helpers/form.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index e8520d847..5869f2d12 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -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)) {