Exactly, this is related with the primary key for your model. See
http://groups.google.com/group/CakePHP-es/t/9503e9e1222d1a08?hl=es (in
spanish) as his original request. ;)

Regards,

-- 
Pablo Viojo
[EMAIL PROTECTED]
http://pviojo.net



On Dec 3, 2007 8:25 PM, kristofer <[EMAIL PROTECTED]> wrote:

>
> Can you post your model? I don't think you should validate the id
> field. Have the DB auto_increment the id field instead.
>
> On Dec 3, 1:29 pm, dandreta <[EMAIL PROTECTED]> wrote:
> > Hi!
> > I have a problem and I cant solve it. I hope you can help me.
> > I have a table called Records with fields Id and Name.
> > I create model, controller and views with bake. In the model I
> > validate that Id and name do not be empty and in the controller I have
> > add function:
> > function add() {
> >                 if (!empty($this->data)) {
> >                         $this->cleanUpFields();
> >                         $this->Record->create();
> >                         if ($this->Record->save($this->data)) {
> >                                 $this->Session->setFlash('The Record has
> been saved');
> >
> $this->redirect(array('action'=>'index'), null, true);
> >                         } else {
> >                                 $this->Session->setFlash('The Record
> could not be saved');
> >                         }
> >                 }
> >         }
> >
> > and my view:
> > <?php echo $form->create('Record');?>
> > <?php
> >                 echo $form->input('id', array('type'=>'text'));
> >                 echo $form->input('name');
> > ?>
> > <?php echo $form->end('Submit');?>
> >
> > The problem is that adding a new register, if I write id and name the
> > record is saved ok, but to verify the validation, the name is
> > validated correctly but, if I write the id and empty name  and click
> > submit appears ok the message of empty name but if I delete Id and I
> > click submit again it jumps to the view of editing the record.
> > Only jumps to editing record but this new empty record is not added to
> > the database.
> > What is the problem? How can I solve it?
> >
> > Thanks and regards
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to