单击时,表Req ..中的所有字段状态变为1 ..
我只有在选择$ req2 [' Req'] [' id']
时才需要更改状态有什么问题??
使用postlink时的观点
<?php echo $this->Form->postLink(__('C'),$this->requestAction(array('controller'=>'Reqs','action' => 'editstatus', $req2['Req']['id'])), null, __('Estas seguro de que quieres cancelar la req # %s?', $req2['Req']['id'])); ?>
我的控制器需求和功能editstatus
public function editstatus($id = null) {
if (!$this->request->is('post') && !$this->request->is('put')) {
throw new MethodNotAllowedException(); }
$this->Req->id = $id;
if ($this->request->is('post') || $this->request->is('put')) {
$this->request->data['Req']['status'] = '1';
if ($this->Req->save($this->request->data)) {
$this->Session->setFlash('Se Grabo la Requisicion'.$id);
} else { $this->Session->setFlash('No se pudo cancelar la Requisicion'.$id);}}}
答案 0 :(得分:0)
在您的视图中,您调用$ this-&gt; requestAction(),这意味着每次生成该链接时,它也会调用“editstatus”操作。
删除$ this-&gt; requestAction(),如下所示:
<?php
echo $this->Form->postLink(__('C'),
array('controller'=>'Reqs','action' => 'editstatus', $req2['Req']['id']),
null,
__('Estas seguro de que quieres cancelar la req # %s?',
$req2['Req']['id']));
?>