/** * Updates an existing Tmp model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if (!Yii::$app->request->get('typeid')) { UHelper::alert('参数缺失,无法添加模板', 'error'); return $this->redirect(['plug/index']); } if ($model->load(Yii::$app->request->post())) { $model->images = JquploadHelper::jqformat(); $model->configs = ArrayHelper::mulitinput(['tmpc_name', 'tmpc_value', 'tmpc_key']); $model->imgconfigs = ArrayHelper::mulitinput(['tmpimg_name', 'tmpimg_width', 'tmpimg_height']); if ($model->save()) { UHelper::alert('更新成功!', 'success'); return $this->redirect(['index', 'typeid' => Yii::$app->request->get('typeid')]); } else { UHelper::alert('更新失败!', 'error'); return $this->redirect(['update', 'id' => $id, 'typeid' => Yii::$app->request->get('typeid')]); } } else { $model->images = JquploadHelper::jqunformat($model->images); $model->configs = ['configs' => [['属性名', 'tmpc_name'], ['默认值', 'tmpc_value'], ['键值', 'tmpc_key']], 'data' => Json::decode($model->configs, 1)]; $model->imgconfigs = ['configs' => [['图片名', 'tmpimg_name'], ['宽度', 'tmpimg_width'], ['高度', 'tmpimg_height']], 'data' => Json::decode($model->imgconfigs, 1)]; // UHelper::output($model->configs); return $this->render('update', ['model' => $model]); } }
/** * Deletes an existing Menu model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $row = $this->findModel($id); $count = Menu::find()->where(['parentId' => $row['id']])->count(); if ($count > 0) { UHelper::alert('菜单下有子菜单,无法删除!'); } else { JquploadHelper::jqdelimages($row['images']); $row->delete(); } return $this->redirect(['index']); }
/** * Deletes an existing Plug model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $model = $this->findModel($id); JquploadHelper::jqdelimages($model->images); $model->delete(); return $this->redirect(['index']); }
/** * Updates an existing Menu model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $request = Yii::$app->request; // if ($model->load(Yii::$app->request->post()) && $model->save()) { // return $this->redirect(['view', 'id' => $model->menu_id]); // } else { // return $this->render('update', [ // 'model' => $model, // ]); // } if ($request->isPost) { $model->load($request->post()); $model->menu_images = JquploadHelper::jqformat(); if ($model->save()) { return $this->redirect(['menu/index']); } } $model->menu_images = JquploadHelper::jqunformat($model->menu_images); return $this->render('update', ['model' => $model]); }