0
我試圖用cakephp中的某些數據庫值填充選擇框。我從數據庫查詢得到的數組如下,如何加載CakePHP中的選擇框
Array (
[0] => Array ([mst_division] => Array ([mstDivisionID] => 1 [Division] => Sydney))
[1] => Array ([mst_division] => Array ([mstDivisionID] => 2 [Division] => Tokyo 3))
[2] => Array ([mst_division] => Array ([mstDivisionID] => 3 [Division] => Osaka 9))
)
我有點困惑,我應該如何加載到選擇框。我的PHP代碼,如下圖所示,
echo $this->Form->input('Division', array(
'type' => 'select',
'options' => $divisions,
'selected' => 2)
);
而我的HTML代碼也會如下圖所示,
<div class="input select"><label for="MemberDivision">Division</label><select name="data[Member][Division]" id="MemberDivision">
</optgroup>
<option value="Division">Sydney</option>
<optgroup label="mst_division">
<optgroup label="1">
</optgroup>
<option value="Division">Tokyo 3</option>
<optgroup label="mst_division">
</optgroup>
<optgroup label="2">
</optgroup>
<option value="Division">Osaka 9</option>
<option value="mstDivisionID">3</option>
<optgroup label="mst_division">
</optgroup>
</select>
</div>
使用$ divisions = $ this-> ModelName-> find('list'); –