In the form of Person_Event model I need to show a cGridView of Event model , BUT , only those which occur on this Week model.
So here is the code I came up with in the Person_Event form (is it appropriate to put it there?) , but I get an SQL syntax error that $week_id doesn't have a value.
I'm not quite sure about some lines , so I marked them with my questions:
<?php $today=date("Y-m-d"); // does it really give today's date? $criteria = new CDbCriteria(); $criteria->condition='start_date<=:today AND end_date>=:today'; //check that today's date is in a certain week? $criteria->params = array(':today'=>$today); $week = Week::model()->findAll($criteria); //finds the week? $week_id=$week->id; //takes the week's id? $this->widget('ext.selgridview.SelGridView', array( 'id'=>'event-grid', 'selectableRows' =>2, 'dataProvider'=>Event::model()->search(array('condition'=>"type_id='conference' AND week_id=$week_id")), 'columns'=>array( //rest of the CgridView. . . . .