Are you including the Model.id field in your edit form view?
<?php echo $form->create("Model"); ?>
<?php echo $form->input("Model.id"); ?> <-- important line
<?php ... rest of fields in your form ?>
<?php echo $form->end("Submit"); ?>
On Jan 16, 4:37 pm, mona <[email protected]> wrote:
> Here is my edit function code i don't know where i mistaken if i edit
> my record it added automatically one new record and i didn't get
> validation messages also below is my edit function code
> function edit($id = null){
> $this->set('sections', $this->Entry->Section->find
> ('list',array
> ('fields'=>'Section.section','Section.id','recursive' => 1,'page' =>
> 1,)));
> if (empty($this->data)){
> if (!$id){
> $this->Session->setFlash('Invalid id for Entry');
> $this->redirect('/entries/index');
> }
> $this->data = $this->Entry->read(null, $id);
> }
> else{
> $query=mysql_query("select max(counter) from entries");
> $row=mysql_fetch_array($query);
> $co=$row[0]+1;
> $q=mysql_query("update entries set counter=$co where id=$id");
> if ($this->Entry->save($this->data)){
> $this->Session->setFlash('The Entry has been saved');
> $this->redirect('/entries/index');
> }
> else{
> $this->Session->setFlash('Please correct errors below.');
> }
> }
> }
>
> can anybody tell me where i m mistaken this function doesn't edit my
> record instead of that it will added one new record in my table
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---