/** * Updates an existing Action 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 ($model->load(Yii::$app->request->post()) && $model->validate()) { $model->data_structure = HelperData::dataTrim($model->data_structure); $model->data_structure = HelperData::dataImplodeReturn($model->data_structure); $model->save(false); //return $this->redirect(['view', 'id' => $model->id]); return $this->redirect(['index']); } else { $model->data_structure = HelperData::dataExplodeReturn($model->data_structure); // add device_ids to the model, that are joined to the action, it // set automaticly the default values of the device_ids $model->device_ids = $model->getDeviceActions(); return $this->render('update', ['model' => $model]); } }
public static function dataRemoveDoubleReturnsAndTrim($data) { // replace returns with , $data = HelperData::dataImplodeReturn($data); // trim all the spaces between the , like , , , ,, to ,, $data = HelperData::dataTrim($data); // replace all the ,, for one , do { $done = strpos($data, ',,'); $data = str_replace(',,', ',', $data); } while ($done); return $data; }