MDL-48165 workshop: Add support for assessment forms validation
authorDavid Mudrák <david@moodle.com>
Tue, 1 Sep 2015 20:57:04 +0000 (22:57 +0200)
committerDavid Mudrák <david@moodle.com>
Tue, 1 Sep 2015 21:37:17 +0000 (23:37 +0200)
mod/workshop/form/edit_form.php

index 89c31fb..708cdc4 100644 (file)
@@ -80,6 +80,23 @@ class workshop_edit_strategy_form extends moodleform {
         $mform->closeHeaderBefore('buttonar');
     }
 
+    /**
+     * Validate the submitted form data.
+     *
+     * Grading strategy plugins can provide their own validation rules by
+     * overriding the {@link self::validation_inner()} method.
+     *
+     * @param array $data
+     * @param array $files
+     * @return array
+     */
+    final public function validation($data, $files) {
+        return array_merge(
+            parent::validation($data, $files),
+            $this->validation_inner($data, $files)
+        );
+    }
+
     /**
      * Add any strategy specific form fields.
      *
@@ -89,4 +106,14 @@ class workshop_edit_strategy_form extends moodleform {
         // By default, do nothing.
     }
 
+    /**
+     * Add strategy specific validation rules.
+     *
+     * @param array $data
+     * @param array $files
+     * @return array
+     */
+    protected function validation_inner($data, $files) {
+        return array();
+    }
 }