Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-34658 - Saving failed because missing or false values

  • Loading branch information...
commit 8821ce4d3d2c58dcb613f81d14dfc458b8fd0f81 1 parent f2ddce9
Andreas Grabs authored August 03, 2012
7  mod/feedback/item/numeric/lib.php
@@ -540,8 +540,13 @@ public function value_type() {
540 540
     }
541 541
 
542 542
     public function clean_input_value($value) {
  543
+        $value = str_replace($this->sep_dec, FEEDBACK_DECIMAL, $value);
543 544
         if (!is_numeric($value)) {
544  
-            return null;
  545
+            if ($value == '') {
  546
+                return null; //an empty string should be null
  547
+            } else {
  548
+                return clean_param($value, PARAM_TEXT); //we have to know the value if it is wrong
  549
+            }
545 550
         }
546 551
         return clean_param($value, $this->value_type());
547 552
     }
7  mod/feedback/lib.php
@@ -2209,10 +2209,13 @@ function feedback_check_values($firstitem, $lastitem) {
2209 2209
         $formvalname = $item->typ . '_' . $item->id;
2210 2210
 
2211 2211
         if ($itemobj->value_is_array()) {
2212  
-            $value = optional_param_array($formvalname, null, $itemobj->value_type());
  2212
+            //get the raw value here. It is cleaned after that by the object itself
  2213
+            $value = optional_param_array($formvalname, null, PARAM_RAW);
2213 2214
         } else {
2214  
-            $value = optional_param($formvalname, null, $itemobj->value_type());
  2215
+            //get the raw value here. It is cleaned after that by the object itself
  2216
+            $value = optional_param($formvalname, null, PARAM_RAW);
2215 2217
         }
  2218
+        $value = $itemobj->clean_input_value($value);
2216 2219
 
2217 2220
         //check if the value is set
2218 2221
         if (is_null($value) AND $item->required == 1) {

0 notes on commit 8821ce4

Please sign in to comment.
Something went wrong with that request. Please try again.