Ok, here's the scenario: I've got a Product model and a ProductType
model. Additionally I have an autoIncrement behavior created (the
database I'm working on has many tables w/out auto-incrementing
primary keys, and I can't change the structure).

I have a function in my ProductType model called newFromName() that
basically just takes a name, creates a new record w/ that name, and
passes back an ID, fairly basic.

My models pass my behavior some settings, and I'm handling them in
what appears to be a pretty standard way from other behaviors I've
seen:

        function setup(&$Model, $settings = array()){

                $this->__defaults = array(
                        'overwrite' => false,
                        'increment' => 1,
                        'conditions' => array(),
                        'direction' => 'DESC',
                        'sameFields' => array(),
                );

                $this->__settings = $settings;

        }

So here's the bizarre part: if I'm in ProductsController and I call
$this->Product->ProductType->newFromName('name'), my AutoIncrement
behavior is getting passed the settings from Product, NOT ProductType.
(I'm debugging out $this->__settings in the behaviors' beforeSave())

I thought it might have something to do with calling the function thru
an associated model (Product->ProductType), so I tried:

$PType = new ProductType;
$PType->newFromName('name');

And the behavior is getting passed the proper settings.

Now it gets stranger - for sh!ts and giggles, I said:

$PType = new ProductType;
$this->Product->ProductType->newFromName('name');

And that worked...

So it seems for some reason, even though I'm not even calling $PType,
leaving in $PType = new ProductType is getting the behavior
ProductType's behavior settings, but without it the behavior is
getting Product's settings.

Does this sound like a bug to anyone else?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to