/ Published in: PHP

This is the basic edit action suggested by the CakePHP Manual
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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 } }
URL: http://manual.cakephp.org/chapter/models
Comments
