【发布时间】:2010-12-22 12:29:55
【问题描述】:
我编写了一个自定义视图,如下所示: http://img405.imageshack.us/i/taula.jpg/
这是我的控制器功能,尚未实现保存数据: http://pastebin.com/cU5rprFB
这是我的观点: http://pastebin.com/4bYLPp4z
我认为写作形式是这样的:
<td>
<input name="data[Linea][0][proyecto_id]" type="hidden" value=" <?php echo $proyecto['Proyecto']['id'] ?>" />
<input name="data[Linea][0][hito_id]" type="hidden" value=" <?php echo $proyecto['Hito']['id'] ?>" />
<input name="data[Linea][0][tarea_id]" type="hidden" value=" <?php echo $proyecto['Tarea']['id'] ?>" />
<input name="data[Linea][0][total_horas]" type="text" id="LineaTotalHotas" value="" >
</td>
就足够了……但事实并非如此。在 debug_kit 中,我看到隐藏数据没问题,但输入的数据丢失了......
有没有人有例子或者什么可以帮助我?
更新:我正在我的控制器中尝试类似的东西:
function addhoras() {
if (!empty($this->data)) {
xdebug_break();
foreach($this->data['Linea'] as $l) {
if ( ($l['total_horas'] != 0) && ( $l['total_horas']!=NULL ) ) {
$this->Linea->create();
if ( $this->Linea->save($l) ) {
} else {
$this->Session->setFlash(__('Arazonbat eon dek', true));
}
}
}
//$this->redirect(array('action' => 'addhoras'));
}
但我在if ( $this->Linea->save($l) ) 行上收到了一个 setflash...所以它没有保存任何数据...这是var_dump($l):
array
'proyecto_id' => string ' 1' (length=2)
'hito_id' => string ' 3' (length=2)
'usuario_id' => string ' 1' (length=2)
'fecha' => string '2011-01-01 ' (length=11)
'total_horas' => string '33' (length=2)
【问题讨论】:
标签: model-view-controller cakephp model view