]> git.mjollnir.org Git - moodle.git/commitdiff
added a method that returns the submitted data without validation MDL-10181, please...
authortoyomoyo <toyomoyo>
Wed, 4 Jul 2007 02:32:08 +0000 (02:32 +0000)
committertoyomoyo <toyomoyo>
Wed, 4 Jul 2007 02:32:08 +0000 (02:32 +0000)
lib/formslib.php

index bdd0d46f621ffb0864d3b9f7f9929e5bbea34ac5..b50db7642dede61c39d900b12192b097ffb59a55 100644 (file)
@@ -369,6 +369,29 @@ class moodleform {
         }
     }
 
+    /**
+     * Return submitted data without validation or NULL if there is no submitted data.
+     *
+     * @param bool $slashed true means return data with addslashes applied
+     * @return object submitted data; NULL if not submitted
+     */
+    function get_submitted_data($slashed=true) {
+        $mform =& $this->_form;
+
+        if ($this->is_submitted()) {
+            $data = $mform->exportValues(null, $slashed);
+            unset($data['sesskey']); // we do not need to return sesskey
+            unset($data['_qf__'.$this->_formname]);   // we do not need the submission marker too
+            if (empty($data)) {
+                return NULL;
+            } else {
+                return (object)$data;
+            }
+        } else {
+            return NULL;
+        }
+    }
+
     /**
      * Save verified uploaded files into directory. Upload process can be customised from definition()
      * method by creating instance of upload manager and storing it in $this->_upload_form