我正在制作一个页面,该页面可以更新特定订单上的销售代理。我列出了选项列表,并创建了一个下拉列表。
控制器中的继承人:
$order = $this->Order->read(null,$id);
$this->set("order",$order);
if ($this->request->is("post")) {
if($this->Order->save($this->request->data)) {
$this->Session->setFlash("Sales Agent Updated");
}
}
这是视图:
echo $this->Form->create("Order");
echo $this->Form->input("OrderID");
echo $this->Form->input("UserID");
echo $this->Form->submit("Submit");
echo $this->Form->end();
当我提交数据时,似乎已保存数据(设置了Flash消息)。
但是,当我用数据库中已经存在的数据预置字段时,突然之间它甚至都不会发布。(我在reques-> is(“ post)条件之后放置了一个调试,提交后该调试不显示)。
$order = $this->Order->read(null,$id);
$this->set("order",$order);
if ($this->request->is("post")) {
if($this->Order->save($this->request->data)) {
$this->Session->setFlash("Sales Agent Updated");
}
}
if (!$this->request->data) {
$this->request->data = $order;
}
输入字段已正确预填,但现在该表单甚至都不会过帐。
有人知道怎么了吗?
谢谢!
将您的控制器代码更新为:
$order = $this->Order->read(null,$id);
$this->set("order",$order);
if ($this->request->is('post') || $this->request->is('put')) {
if($this->Order->save($this->request->data)) {
$this->Session->setFlash("Sales Agent Updated");
}
}
现在,在reques->is('post')
条件之后放置一个调试,它将显示您需要显示的内容。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句