cascading different controller actions

Hello,

i have two controllers that i want if a method of controller A is called simutenously

the method of controller B will execute

how do i go about it ? any IDEA??? :huh: :huh: :huh:

thanks in advance

could you be more specific about your scenario and expected output?

I kind of sounds like you are looking to implement a behaviour, something like when we save a record, do something automatically.

doodle :mellow:

Actually i have a Profile controller different from my User Controller (used for my authentication) i want to give the Admin a role when He (admin) disable or delete a user profile the corresponding row in User table is deleted by User the Controller method(delete)

Actually i have a Profile controller different from my User Controller (used for my authentication) i want to give the Admin a role when He (admin) disable or delete a user profile the corresponding row in User table is deleted by User the Controller method(delete)

Controllers should be independend from each other, you should never call a function in a controller from another controller.

In your case I think that you can write the function you need in the model user itself, and use in both controllers.

Other options are to create a component (a class in the component dir) and put your function here.

thanks for these very basic understanding that everyone need to have in MVC structure :rolleyes: :rolleyes:

i think writing a component will be my best option for now ;D ;D

thanks

Have you checked the beforeDelete() events of your model classes?

CActiveRecord::beforeDelete()

You can also make use of the beforeSave() event in order to make changes to the profile table accordingly.

There you can create a sqlcommand that updates related tables before any of the above mentioned actions.

Just an idea… is how I do it anyway.

PS: I am with Zac, forget about relating controllers… isolate them is the best approach.

It sounds almost like the poster is asking for Observer functionality, which I’ve seen discussed but not implemented for Yii yet. Observers seem to be somewhat similar to a Behavior