/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'update' page.
  */
 public function actionCreate()
 {
     $this->breadcrumbs = array('Шаблон фотогалереи' => array('/photo/phototemplate'), 'Новая запись');
     $model = new PhotoTemplate();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     // set attributes from get
     if (isset($_GET['PhotoTemplate'])) {
         $model->attributes = $_GET['PhotoTemplate'];
     }
     if (isset($_POST['PhotoTemplate'])) {
         $model->attributes = $_POST['PhotoTemplate'];
         //Может быть только 1 шаблон используемый на фронте
         if ($model->active == 1) {
             //Проставляем всем остальным 0
             PhotoTemplate::model()->updateAll(array('active' => 0));
         }
         if ($model->save()) {
             $url = isset($_POST['go_to_list']) ? $this->listUrl('index') : $this->itemUrl('update', $model->id);
             $this->redirect($url);
         }
     }
     $this->render('create', array('model' => $model));
 }