/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new SchoolCalendar();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['SchoolCalendar'])) {
         $model->attributes = $_POST['SchoolCalendar'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     if (isset($_GET['school_year_id'])) {
         $model->school_year_id = $_GET['school_year_id'];
     }
     $this->render('create', array('model' => $model));
 }
 public function actionPopulate()
 {
     $model = $this->loadModel();
     foreach (KDateArray::createWeekdayRangeArray($model->start_date, $model->end_date) as $d) {
         $sc = new SchoolCalendar();
         $sc->school_day = $d;
         $sc->school_year_id = $model->id;
         // TODO: trap errors here somehow
         $sc->save();
     }
     $this->redirect(array('view', 'id' => $model->id));
 }