I am a Yii newbie who is trying to understand how this particular situation would be handled.
If I have 2 models,
The first model contains date and other information pertaining to the model. The second model contains date and information pertaining to the second model.
I want to have a search where I enter the date - from there the information from both the first and second model are pulled and displayed for the given date.
What is the proper way to structure this in Yii?
Would I just add an action to one of the controllers? This seems somewhat arbitrary, as neither model is really connected to the other, besides the date.
Or do I just create a controller with no related model?
Your feedback is appreciated, as I am trying to understand the idea behind Yii.
I know there is a blog example, but in that case it would seem that the "post" model is the "main" element, and "comments" would be pulled and displayed for the relevant "post". But in my situation I'm curious how it is ideally structured, where the 2 models don't really have that kind of dependancy, but instead their only connection is the date.
Thank you.
First, properly define relations in your table/model.
Your controller code will change a bit to process both the models.
Do the processing, loading model data/setting attributes etc..
Pass both the models instance to view.
In the view you can define fields/grid etc that renders data from both the models. You have to define/specify which associates with which fields.