1
大家好我有一個視圖下拉框。我有一個查找語句,返回一個模板列表,當我調試查找時,它會打印出正確的template.id和template.name列表,但是當我提交表單時它攜帶的數字在列表中,例如如果我在列表中選擇第五個模板,它將保存template_id = 5而不是實際的模板ID號。cakephp下拉框和數組
//Retrieve Account Id of current User
$accountid=$this->Auth->user('account_id');
//conditions for template arrays
$conditions=
array('AND' => array(
array('Template.account_id' => $accountid),
array('Template.active' => 1)
));
//An array of all Templates belonging to the current User's Account
$templates=$this->Template->find('list', array(
'conditions' => $conditions));
當我調試$模板,我得到這個打印出來
array(
(int) 1 => 'Consulting- Bus',
(int) 2 => 'Consulting- Pers',
(int) 7 => 'ClientEdge',
(int) 8 => '11111',
(int) 9 => 'testSUn',
(int) 10 => 'Test Bruce Review',
(int) 11 => 'Test Bruce 3 = Final'
當我選擇例如「測試布魯斯評論」,並點擊提交和調試它打印出的值「6」,6號當我調試它時,我希望它打印出10個項目。
這裏從形式片段與此下拉框
<tr><td><?php echo "Template: "?></td>
<td><?php echo $this->Form->input('template_id', array('label'=>false,'type'=>'select','options'=>$templates));?></td></tr>
我怎樣才能解決這個問題?