On 9/14/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
.....clipped........

What I want to do is simple - take the original Applicant record
(schoolyear = 16) and copy them to a new record, with all the same
data, except that the schoolyear = 15.

                        $this->Applicant->id = $id;
                        $this->data = ""
                        $this->data['Applicant']['id'] = null;
                        $this->data['Applicant']['schoolyear_id'] = 15;
                        $this->Applicant->save($this->data['Applicant']);

What I get are three new records, all of them with the schoolyear = 15.
The original record remains.


Instead of setting the id to null (i.e. $this->data['Applicant']['id'] = null; )

Try doing this...

unset( $this->data['Applicant']['id'] );

I don't know exactly what the save() code in the model is doing to create 3 entries because I have not looked, but setting the value to null still leaves that entry in the array defined; it is just set to null.  Using unset() will actually remove it from the array so that when the data is passed to the save command it will look just like it does when you are adding an entry via a normal "add" form.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to