Skip to content

Commit

Permalink
fix(radiosfield, selectfield): check default value before save
Browse files Browse the repository at this point in the history
if the value is invalid (not in the list of possible values), an error will occur
  • Loading branch information
btry committed Apr 17, 2023
1 parent f258812 commit d4a2ecb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions inc/field/radiosfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ public function prepareQuestionInputForSave($input) {
$input['values'] = $this->trimValue($input['values']);
$input['default_values'] = trim($input['default_values']);

if (!$this->isValidValue($input['default_values'])) {
Session::addMessageAfterRedirect(
__('The default value is invalid:', 'formcreator') . ' ' . $input['name'],
false,
ERROR
);
return [];
}

return $input;
}

Expand Down

0 comments on commit d4a2ecb

Please sign in to comment.