Skip to content

Commit

Permalink
fix(fields): add default value to prevent SQL error (#2965)
Browse files Browse the repository at this point in the history
  • Loading branch information
stonebuzz authored and btry committed Oct 13, 2022
1 parent 3d94048 commit 19f0395
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion inc/field/fieldsfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,15 @@ public function parseAnswerValues($input, $nonDestructive = false): bool {
$decodedValues = json_decode($this->question->fields['values'], JSON_OBJECT_AS_ARRAY);
$field_name = $decodedValues['dropdown_fields_field'] ?? '';
$dropdown_field_name = "plugin_fields_" . $decodedValues['dropdown_fields_field'] . "dropdowns_id" ?? '';
$value = '';

// compute default value
$field = new PluginFieldsField();
$field->getFromDbByCrit(['name' => $field_name]);
if ($field->fields['type'] == 'dropdown') {
$value = 0;
} else {
$value = '';
}

if (isset($input[$field_name])) {
$value = $input[$field_name];
Expand Down

0 comments on commit 19f0395

Please sign in to comment.