Skip to content

Commit

Permalink
Merge pull request #164 from PrestaSafe/fix-update-config
Browse files Browse the repository at this point in the history
Fix update config
  • Loading branch information
PrestaSafe authored Nov 13, 2023
2 parents 04d57d3 + 2b6f4db commit 415ca86
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions classes/PrettyBlocksModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,18 @@ public function updateConfig($stateRequest)
$fields = [];
$stateRequest = json_decode($stateRequest, true);
$fieldsRequest = array_filter($stateRequest, function ($field) {
return isset($field['type']);
return isset($field['type']) && $field['type'] !== 'title';
});

foreach ($fieldsRequest as $key => $field) {
$obj = (new FieldCore($field))->setAttribute('new_value', $field['value']);
$fields[$key] = $obj;
}
$this->setConfigFields($fields);
$this->config = $this->generateJsonConfig();
$existingConfig = json_decode($this->config, true);
$newConfig = json_decode($this->generateJsonConfig(), true);
$mergedConfig = array_merge($existingConfig, $newConfig);
$this->config = json_encode($mergedConfig);
$template_name = pSQL($stateRequest['templateSelected']);
$this->setCurrentTemplate($template_name);
$this->setDefaultParams($stateRequest['default']);
Expand Down

0 comments on commit 415ca86

Please sign in to comment.