/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Day();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Day'])) {
         $model->attributes = $_POST['Day'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
示例#2
0
 public function duplicate($modify = array())
 {
     $clone = new Day();
     $clone->attributes = $this->attributes;
     $clone->id = null;
     foreach ($modify as $key => $value) {
         $clone->{$key} = $value;
     }
     if ($clone->save()) {
         // Сохраняем страницы
         $result = true;
         foreach ($this->pages as $page) {
             $result = $page->duplicate(array('day_id' => $clone->id));
         }
         return $result;
     }
     return false;
 }