I’ve got a Client model which is interactive (the user is performing CRUD operations with it).
One of the functions is to schedule an Appointment connected to a calendar Event. There is an Appointment model holding info such as Client ID (FK), Location, etc for that. And there is an Event model (belonging to the interactive Calendar module) which has an Appointment ID (FK). Note that the Appointment model is never interacted with by the user directly.
So, the steps are something like this…
[indent]
The user requests to schedule an appointment for a specific client (Client Id provided by URL)
Now this is where I need some advice:
An Appointment record has to be created - but by who? I assume the AppointmentController should do this?
Let’s assume the AppointmentController has created a new record for us. The Appointment ID then has to be passed on to the Calendar controller somehow. I guess this is where I’m a bit confused. How should I call another controller (should I even do that??) and how to pass parameters? (unless in the URL)[/indent]
Also I’d like to know if using Yii::app()->user->getState/setState to pass around parameters is good practice or if there’s a better way?
No, I mean if it’s “good practice” to use get/setState for passing parameters between objects between page loads. I’m still not grasping how that is supposed to be done (except through the URL), which is a part of my problem above.
I thought GET (or $_GET?) only was used to read variables from a Form?
Ah yes, that’s what I meant. Thanks for formulating it in a correct way What about step 3. - transfering the control to another controller? How can that be done? Can i ‘render’ another controller or redirect the browser? Or am I heading the wrong way here? Can I for instance do something like this:
In AppointmentController:
$eventctrl = new EventController;
$eventctrl->actionSchedule($appointment->id);
After some digging on this topic I’ve come to the conclusion that simply redirecting the browser using redirect() is the preferred way to transfer control from one controller to another. Is this correct?