/** * Updates an existing Plug 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); $RQ = \Yii::$app->request; if (empty($model->images)) { $model->images = [['label' => '示例图片', 'width' => 200, 'height' => 200]]; } else { $model->images = JquploadHelper::jqunformat($model->images); } if ($RQ->isPost) { $model->load($RQ->post()); $model->images = JquploadHelper::jqformat(); if ($model->save()) { UHelper::alert('修改成功!', 'success'); return $this->redirect(['update', 'id' => $model->id]); } else { UHelper::alert('修改失败', 'error'); } } return $this->render('update', ['model' => $model]); }
/** * 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]); } }
/** * 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); $RQ = Yii::$app->request; if ($RQ->isPost) { $model->load($RQ->post()); $model->images = JquploadHelper::jqformat(); $model->share = Json::encode($RQ->post('share')); if ($RQ->post('Menu[type]') != 1 && Menu::find()->where(['parentId' => $id])->count()) { //下面有子菜单的时候,必须选择类型为1 UHelper::alert('此菜单下有子菜单,必须选为菜单模型!', 'error'); return $this->redirect(['update', 'id' => $id]); } if ($model->save()) { UHelper::alert('更新成功', 'success'); } else { UHelper::alert('更新失败', 'error'); } return $this->redirect(['index']); } else { $model->images = JquploadHelper::jqunformat($model->images); $share = Json::decode($model->share, 1); $model->share = [['分享标题', 'share[title]', $share['title'], '分享出去的标题'], ['分享描述', 'share[desc]', $share['desc'], '分享出去的描述']]; return $this->render('update', ['model' => $model, 'plugArray' => $this->plugList(), 'menuList' => Menu::findlist()]); } }
/** * 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]); }