Thanks Chris and Steve, this works. But I've got a small problem now
with afterSave().

When using afterSave() to receive the lastInsertId it seems like the
$this->data object from mymodel->afterSave() is not the same as in
mycontroller->[directly after saving the data set].

Step by step:

// controller does:
function myAction() {
  if ($this->myModel->save()) {
    // second print_r
    print_r($this->data);
  }
}

// model has:
afterSave() {
  $this->data['User']['id'] = $this->getLastInsertId();
  // first print_r
  print_r($this->data);
}

This aims to give me the generated userid to send an activation email
to the user. To make sure each step is executed at the right moment
and to check the data, I inserted the print_r commands. The output
tells me I'm correct, first print_r comes before second print_r. BUT
first print_r outputs the userid as received with getLastInsertId and
the second print_r does _not_.

Do you know how to solve this? Seems to me like these datasets weren't
the same, though they should be, or am I that false with that?

Thanks in advance

Arne

On Nov 9, 3:31 am, Steve Boyd <[EMAIL PROTECTED]> wrote:
> just add it to $this->data
>
> i.e. (haven't tested but along these lines)
>
> $this->data['myvar'] = 'myval';
> $this->data->save();
>
> On Nov 9, 2:38 pm, Arne-Kolja Bachstein <[EMAIL PROTECTED]> wrote:
>
> > Hi there,
>
> > how could I add a variable to $this->data before saving, that
> > shouldn't be generated throughout the form it is associated to? :-)
>
> > Thanks in advance
>
> > Arne


--~--~---------~--~----~------------~-------~--~----~
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