From dd31275831bbc686ac0e2696d91fd6e51e91ec78 Mon Sep 17 00:00:00 2001 From: Prestasafe Date: Fri, 4 Aug 2023 08:49:31 +0200 Subject: [PATCH] fix save state --- classes/PrettyBlocksModel.php | 7 ++++--- controllers/front/ajax.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/classes/PrettyBlocksModel.php b/classes/PrettyBlocksModel.php index fb99c123..2c3af842 100644 --- a/classes/PrettyBlocksModel.php +++ b/classes/PrettyBlocksModel.php @@ -200,14 +200,15 @@ public function saveConfigField($name, $new_value) */ public function saveStateField($index,$name,$new_value) { + // get state in json, replace it if exist and save model. if(isset($this->stateFields[$index][$name])){ $newField = $this->stateFields[$index][$name]->setAttribute('new_value',$new_value)->compile(); $jsonConfig = json_decode($this->state, true); if (is_null($jsonConfig)) { - $json = []; + $jsonConfig = []; } - $json[$index][$name] = $newField; - $this->state = json_encode($json, true); + $jsonConfig[$index][$name] = $newField; + $this->state = json_encode($jsonConfig, true); return $this->save(); } return false; diff --git a/controllers/front/ajax.php b/controllers/front/ajax.php index 3f567837..688b8122 100755 --- a/controllers/front/ajax.php +++ b/controllers/front/ajax.php @@ -382,7 +382,7 @@ public function displayAjaxupdateTitleComponent() { // save state $index = (int)Tools::getValue('index'); - dump(Tools::getAllValues()); + if($model->saveStateField((int)$index, pSQL(Tools::getValue('field')), $element)) { $success = true;