Skip to content

Commit d4a2ecb

Browse files
committed
fix(radiosfield, selectfield): check default value before save
if the value is invalid (not in the list of possible values), an error will occur
1 parent f258812 commit d4a2ecb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

inc/field/radiosfield.class.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ public function prepareQuestionInputForSave($input) {
121121
$input['values'] = $this->trimValue($input['values']);
122122
$input['default_values'] = trim($input['default_values']);
123123

124+
if (!$this->isValidValue($input['default_values'])) {
125+
Session::addMessageAfterRedirect(
126+
__('The default value is invalid:', 'formcreator') . ' ' . $input['name'],
127+
false,
128+
ERROR
129+
);
130+
return [];
131+
}
132+
124133
return $input;
125134
}
126135

0 commit comments

Comments
 (0)