這是我add.tcp ...
<?php
echo $this->Form->create('Group');
echo $this->Form->input('group_id', array('label' => 'ID'));
echo $this->Form->input('group_desc', array('label' => 'Group Description'));
echo $this->Form->end('Save');
?>
表名:組 表字段:GROUP_ID,group_desc PK:GROUP_ID
這是我的控制器 ...
class GroupsController extends AppController {
public $helper = array('Html', 'Form', 'Session');
public $components = array('Session');
public function add() {
if ($this->request->is('post')) {
if ($this->Group->save($this->request->data)) {
$this->session.setFlash('');
$this->redirect(array('action' => 'index'));
}
}
}
}
當我在瀏覽器上顯示這一觀點,沒有任何的領域GROUP_ID但有對group_desc,對於這個樣子的 HTML源...
<form action="/cakephp/index.php/groups/add" id="GroupAddForm" method="post" accept-charset="utf-8" name="GroupAddForm">
<div style="display:none;">
<input type="hidden" name="_method" value="POST">
</div><input type="hidden" name="data[Group][group_id]" id="GroupGroupId">
<div class="input text">
<label for="GroupGroupDesc">Group Description</label><input name="data[Group][group_desc]" maxlength="15" type="text" id="GroupGroupDesc">
</div>
<div class="submit">
<input type="submit" value="บันทึก">
</div>
</form>
爲什麼它被隱藏?
歡迎來到SO Ceeram :) – Dunhamzzz 2012-07-27 10:21:19
謝謝,我認爲是時候創建一個帳戶,所以我可以回覆 – Ceeram 2012-07-27 21:43:32