Ejemplo n.º 1
0
 /**
  * Creates a new model
  * If creation is successful, the browser will be redirected to the 'view' page
  *
  * @param integer $id_category
  */
 public function actionCreate($id_category = null)
 {
     $model = new CatalogService();
     $serviceImages = new CatalogImage();
     if ($id_category === null) {
         $this->breadcrumbs['Управление услугами'] = array('/services');
         $this->breadcrumbs[] = 'Добавление услуги';
     } else {
         $model->id_category = 0;
         //$id_category если категория выбирается из списка
         $this->breadcrumbs = CatalogCategory::getParents($model->id_category, true);
         $this->breadcrumbs[] = 'Добавление услуги';
     }
     if (isset($_POST['CatalogService'])) {
         $model->attributes = $_POST['CatalogService'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model, 'serviceImages' => $serviceImages));
 }