Skip to content
Snippets Groups Projects
Verified Commit 49b92d90 authored by Damien's avatar Damien
Browse files

FEAT #12636 TIME 0:15 Fix change value custom fields with select

parent aaa4face
No related branches found
No related tags found
No related merge requests found
......@@ -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([
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment