Skip to content

Commit

Permalink
fix save state
Browse files Browse the repository at this point in the history
  • Loading branch information
PrestaSafe committed Aug 4, 2023
1 parent 39059ae commit dd31275
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions classes/PrettyBlocksModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion controllers/front/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit dd31275

Please sign in to comment.