Return to Snippet

Revision: 5797
at April 4, 2008 20:12 by jesse

Initial Code
function edit($id)

   //Note: The property model is automatically loaded for us at $this->Property.

   // Check to see if we have form data...
   if (empty($this->data))
        $this->Property->id = $id;
        $this->data = $this->Property->read();//populate the form fields with the current row
      // 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

Initial URL

Initial Description
This is the basic edit action suggested by the CakePHP Manual

Initial Title
CakePHP Controller::edit method

Initial Tags
php, cakephp

Initial Language