tags:

views:

124

answers:

2

I have used cakePHP 1.2 and know how to use behaviors in it.

using cakephp 1.1 on a new project(i know it might sound silly but the project is very similar to an older project we have which was built on 1.1).

after a little googling i have come to believe that cakephp 1.1 models did not have behaviors. cannot find any reference in the manual as well.

is there a way around this? would be nice to have the containable behavior.

Cheers

+2  A: 

Behaviors were indeed introduced in the 1.2 branch.

I think the best thing to do would be to take the time to update your app to 1.2. The Cake 1.1 branch is just so terribly outdated by now. The biggest practical change is that forms are created with the FormHelper instead of the HtmlHelper now, so if you have a lot of forms it's a lot of find/replace. The rest should be pretty compatible right away.

You could of course hack your own "behaviors" using callbacks like beforeSave to invoke some actions, but I don't think it's worth it.

deceze
+1  A: 

Deceze is right. Behaviors wasn't introduced until the 1.2 branch. When I was doing my early developing, I wrote a behavior and realized that behaviors didn't exist yet.

If you simply can't upgrade, then using the app_model would be your best bet. I would start by importing/declaring the behavior I'm interested in. Then I would go through all of the beforeSaves, afterSaves, etc and explicitly call that behavior's methods at the appropriate places.

But again, it may be easier overall to upgrade to 1.2.

Dooltaz