Greetings,
I am a bit new to cake, and am diving in via the cookbook. I have a
simple app I am trying to develop, and am modifying the cookbook
example to fit it. So far everything has worked great with one
exception. I have an edit form that when I go to it it fills in with
the DB data from the record previously selected (on the index page).
However, once I change any information and try to submit it, I receive
the following:
SQL Error: 1062: Duplicate entry '1' for key 1 [CORE/cake/libs/model/
datasources/dbo_source.php
The query string tells me that the form is attempting to perform an
INSERT Into instead of an UPDATE command on the database, causing the
failure. I am not sure why it is doing this... Here is my edit.ctp
content:
<h1>Edit Comment</h1>
<?php
echo $form->create('Comment', array('action' => 'edit'));
echo $form->input('name'); //text
echo $form->input('com_date'); //day, month, year, hour, minute,
meridian
echo $form->input('comment', array('rows' => '3'));
echo $form->input('ID', array('type' => 'hidden'));
echo $form->end('Update Information');
?>
and here is the edit section from the controller:
function edit($id = null) {
$this->Comment->id = $id;
if (empty($this->data))
{
$this->data = $this->Comment->read();
}
else
{
if($this->Comment->save($this->data))
{
$this->Session->setFlash('Your comment has been updated.
','/comments/');
}
}
}
any suggestions as to what I am doing wrong?
Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---