How To Avoid Calling Another Controller Action

Hi,

i am quite new to fantastic framework yii and programming my own simple social network. I am now facing a problem - each user has his own photo galleries, can create them, edit etc. I have a PhotoGallery controller for this with dedicated actions. What I want to do is, that during first login, a photo gallery called "Profile pictures" will be created. This will happen in different Controller. What I would do is, that I would create new form accepted by createGallery action and pass it there. What I have read, this should not be done. How can I do it correctly? This is basically question for everything, what will be created automatically without user form entries. Thank you very much.

Hey,

Can you give the name of your models and controllers? Usually there is one model and controller for each table in your database. Did you use gii to generate the application? It is okay to redirect from one controller to another.

well I have PhotoGalleryController and actionCreateGallery action which creates gallery. This action uses GalleryCreateForm model. I used gii for generating, but everything was edited to suite my needs. Then I have ActivationController which is used for activating user account. During activation I would like to create gallery for profile photos. So I would create model GalleryCreateForm and pass it to actionCreateGallery and it would be done. But what I have read, calling actions from different controller is not “clean” coding. Another problem is, that this action would redirect me somewher else, than I would need, beacuse on succes there is $this->redirect(array(‘photoGallery/view’… So what should I do?

sorry for the delay. You just user redirect. This is how Yii routes to your controllerID and actionID.

http://www.yiiframework.com/doc/api/1.1/CController#redirect-detail

Here’s an example:




$this->redirect(array("createGallery/create/$id"));  // this redirects to Project/Comment

// /$id is passing a parameter to the action.  There are other ways to pass parameters.  Just look for examples.



simply create new GalleryCreateForm at the time of activation , in the same action after activation was successful .