Ejemplo n.º 1
0
 /**
  * Create a new Term for non-hierarchical Taxonomy through Selectize box.
  *
  * @return string
  */
 public function actionAjaxCreateNonHierarchical()
 {
     $model = new Term();
     Yii::$app->response->format = Response::FORMAT_JSON;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return ['id' => $model->id, 'name' => $model->name];
     }
     return [];
 }
Ejemplo n.º 2
0
 /**
  * View single taxonomy and list all term from it.
  *
  * @param integer $id
  *
  * @return mixed
  */
 public function actionView($id)
 {
     $term = new Term();
     $searchModel = new TermSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $id);
     if ($term->load(Yii::$app->request->post())) {
         $term->taxonomy_id = $id;
         if ($term->save()) {
             return $this->redirect(['/taxonomy/view', 'id' => $id]);
         }
     }
     return $this->render('view', ['model' => $this->findModel($id), 'term' => $term, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }