hi, this is the code for edit
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 = $this->Article->findByArticleId($id);
}
and for the view
<?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'); ?>
the problem is it always adds a new record instead of updating the current record. how can I fix it?