Very new to Yii and I have a simple question.
I understand how to pass a model to a view from a controller.
In my case, I have this in a controller:
public function actionView()
{
$id = $_GET['id'];
$event = Event::model()->with('eventRecords')->findAllByPk($id);
if($event) {
$this->render('view', array('event' => $event)); }
}
Now, this is always going to return exactly 1 Event (and one-to-many eventRecords).
This works in my view if I treat it as an array such as:
$event[0]->title
Does Yii always pass to the view as an array? I see the blog demo "view post" function is the same way and uses a loop in "view" and displays everything in "_view" so everything in _view can just be $event->fieldname.
Am I understanding this correctly?
I tried passing a single value to view (as in $foo = ‘bar’) but it doesn’t work as expected. Am I missing something?