这是我的 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');
?>
表名:groups 表字段: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>
为什么被隐藏了?