how to update record in cakephp

ABKThor

New Member
this is the code for edit\[code\]function edit($id){ if(!empty($this->data)) { if($this->Article->save($this->data)) { pr($this->Article); $this->Session->setFlash("Article Saved!"); $this->redirect('/articles/view'); } } else $this->data = http://stackoverflow.com/questions/3595981/$this->Article->findByArticleId($id);}\[/code\]and for the view\[code\]<?php echo $form->create('Article', array('type' => 'post','action'=>'edit')); ?><table><tr><td>Edit Article</td></tr><tr><td>Title: </td><td><?php echo $form->text('article_title',array('label'=>false,'type'=>'text','size'=>50)); ?></td></tr><tr><td>Text: </td><td><?php echo $form->textarea('article_text',array('label'=>false,'class'=>'ckeditor','columns'=>100,'row'=>8,'width'=>100));?></td></tr><tr><td>Published: </td><td><?php echo $form->radio('article_published',array('1'=>'Yes','0'=>'No'),array('legend'=>false));?></td></tr></table><?php echo $form->end('Save'); ?>\[/code\]the problem is it always adds a new record instead of updating the current record. how can I fix it?
 
Back
Top