You don't
For both saving or editing, you should follow this order of
operations:
$this->Model->create($this->data['Model']);
$this->Model->save();
The create function will look for an id passed in the $this->data for
the model. If it sees one, it understands the save should perform an
update, if there is no id, it understands the save as an insert.
- James
On Apr 24, 6:53 am, rtanz <[EMAIL PROTECTED]> wrote:
> Hi why is it that in the add function you use $this->data when saving
> and in the edit function you use $this->data['Post']?
>
> function add() {
> if (!empty($this->data)) {
> if ($this->Post->save($this->data)) {
> $this->flash('Your post has been
> saved.','/posts');
> }
> }
> }
>
> function edit($id = null) {
> $this->Post->id = $id;
> if (empty($this->data)) {
> $this->data = $this->Post->read();
> } else {
> if ($this->Post->save($this->data['Post'])) {
> $this->flash('Your post has been updated.','/posts');
> }
> }
>
> }
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---