I dug a bit deeper and found this buried in the save:
if (!empty($joined) && $success === true) {
$this->__saveMulti($joined, $this->id);
}
What this does is prior to the main record save, an array called $joined is
populated with your relationships from the calling model (I believe it was
Project), so your ProjectTasks are auto saved if they exist in the data array
that is saved.
You can manage this though. There few options I suppose:
1) Unbind your relationships prior to Project->save() and manage the
saves manually in your afterSave as you want to do now. This should
force the saves to happen as you expect. This is a bit kludgy but
workable under your current code base.
2) Copy the ProjectTask data out of the data you pass to Project->save
and put it somewhere you will play with later. Not the cleanest approach.
3) This might be tricky, but is probably most ideal and complies best
with the framework architecture: Call the ProjectTask beforeSave() inside
the Project beforeSave and pass/assign the array of ProjectTask data to it.
The ProjectTask beforeSave needs to be able to detect the array vs. a
single value, but otherwise this is probably the best solution.
Good luck,
Fred
Joshua McFarren wrote:
>> Have you tried deleting all the files that have accumulated in my app/
>> tmp/cache directory. Sometimes when I have had these kinds of strange
>> problems it was because of an outdated cached model file.
>>
>
> Hi Aran,
>
> I deleted the cache and unfortunately that didn't help. I'm pretty
> sure the wrong Model:save() is being called. I need to figure why
> ProjectTask::save() is not handling this. Still stumped and its
> probably something very obvious.
>
> Best,
> Joshua
>
>
>> sparked an idea to override ProjectTask::save() to see if that's even
>> being called and its not!
>>
>> class ProjectTask extends AppModel {
>> var $name = 'ProjectTask';
>> function save() {
>> echo "ProjectTask::save()<br>";
>> exit;
>> }
>> }
>>
>> Yet the data is being stored in the DB. So it must be saving through
>> Schedule::save(). ProjectTask and Schedule are associated models so I
>> guess that's possible right? How can I force ProjectTask::save() to
>> handle this?
>>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---