You can use $this->data['Post'] in add too.
But if $this->data contains associated model for example ['Category']
array, Only Post data will be saved.
You should use $whitelist param in save() too. Check API. model->save
On Apr 24, 12:53 pm, 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
-~----------~----~----~----~------~----~------~--~---