CakePHP Controller::edit方法
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CakePHP Controller::edit方法相关的知识,希望对你有一定的参考价值。
This is the basic edit action suggested by the Cakephp Manual
function edit($id) { //Note: The property model is automatically loaded for us at $this->Property. // Check to see if we have form data... { $this->Property->id = $id; $this->data = $this->Property->read();//populate the form fields with the current row } else { // Here's where we try to save our data. Automagic validation checking if ($this->Property->save($this->data['Property'])) { //Flash a message and redirect. $this->flash('Your information has been saved.', '/properties/view/'.$this->data['Property']['id'], 2); } //if some fields are invalid or save fails the form will render } }
以上是关于CakePHP Controller::edit方法的主要内容,如果未能解决你的问题,请参考以下文章
为啥 Cakephp 的 Controller 第二个测试用例总是失败
使用单独的Controller名称空间时CakePHP 3路由