MDL-34658 - Saving failed because missing or false values

This commit is contained in:
Andreas Grabs
2012-08-03 12:00:22 +02:00
parent f2ddce97bd
commit 8821ce4d3d
2 changed files with 11 additions and 3 deletions
+6 -1
View File
@@ -540,8 +540,13 @@ class feedback_item_numeric extends feedback_item_base {
}
public function clean_input_value($value) {
$value = str_replace($this->sep_dec, FEEDBACK_DECIMAL, $value);
if (!is_numeric($value)) {
return null;
if ($value == '') {
return null; //an empty string should be null
} else {
return clean_param($value, PARAM_TEXT); //we have to know the value if it is wrong
}
}
return clean_param($value, $this->value_type());
}
+5 -2
View File
@@ -2209,10 +2209,13 @@ function feedback_check_values($firstitem, $lastitem) {
$formvalname = $item->typ . '_' . $item->id;
if ($itemobj->value_is_array()) {
$value = optional_param_array($formvalname, null, $itemobj->value_type());
//get the raw value here. It is cleaned after that by the object itself
$value = optional_param_array($formvalname, null, PARAM_RAW);
} else {
$value = optional_param($formvalname, null, $itemobj->value_type());
//get the raw value here. It is cleaned after that by the object itself
$value = optional_param($formvalname, null, PARAM_RAW);
}
$value = $itemobj->clean_input_value($value);
//check if the value is set
if (is_null($value) AND $item->required == 1) {