diff --git a/src/app/customField/controllers/CustomFieldController.php b/src/app/customField/controllers/CustomFieldController.php index 5620fef61a8bd9f98a9dba5089231c9e934afafc..b1fbdc28467b0baf8045a7b164a67939bf35d7d4 100644 --- a/src/app/customField/controllers/CustomFieldController.php +++ b/src/app/customField/controllers/CustomFieldController.php @@ -110,7 +110,7 @@ class CustomFieldController return $response->withStatus(400)->withJson(['errors' => 'Custom field with this label already exists']); } - if (in_array($field['type'], ['select', 'checkbox', 'radio'])) { + if (in_array($field['type'], ['checkbox'])) { $values = json_decode($field['values'], true); foreach ($values as $key => $value) { if (!empty($body['values'][$key]) && $body['values'][$key] != $value) { @@ -126,6 +126,17 @@ class CustomFieldController ]); } } + } elseif (in_array($field['type'], ['select', 'radio'])) { + $values = json_decode($field['values'], true); + foreach ($values as $key => $value) { + if (!empty($body['values'][$key]) && $body['values'][$key] != $value) { + ResModel::update([ + 'postSet' => ['custom_fields' => "jsonb_set(custom_fields, '{{$args['id']}}', '\"{$body['values'][$key]}\"')"], + 'where' => ['1 = ?'], + 'data' => [1] + ]); + } + } } CustomFieldModel::update([