Permalink
Browse files

MDL-28520: repositories: validation method to repository_type_form class

  • Loading branch information...
1 parent 6f05796 commit 84ee73ee3bd49ffc6531cf0d334aaf11fdae7710 Ruslan Kabalin committed Jul 28, 2011
Showing with 27 additions and 0 deletions.
  1. +27 −0 repository/lib.php
View
27 repository/lib.php
@@ -1658,6 +1658,18 @@ public function type_config_form($mform, $classname = 'repository') {
}
/**
+ * Validate Admin Settings Moodle form
+ * @param object $mform Moodle form (passed by reference)
+ * @param array array of ("fieldname"=>value) of submitted data
+ * @param array array of ("fieldname"=>errormessage) of errors
+ * @return array array of errors
+ */
+ public static function type_form_validation($mform, $data, $errors) {
+ return $errors;
+ }
+
+
+ /**
* Edit/Create Instance Settings Moodle form
* @param object $mform Moodle form (passed by reference)
*/
@@ -1941,6 +1953,21 @@ public function definition() {
$this->add_action_buttons(true, get_string('save','repository'));
}
+
+ public function validation($data) {
+ $errors = array();
+ $plugin = $this->_customdata['plugin'];
+ $instance = (isset($this->_customdata['instance'])
+ && is_subclass_of($this->_customdata['instance'], 'repository'))
+ ? $this->_customdata['instance'] : null;
+ if (!$instance) {
+ $errors = repository::static_function($plugin, 'type_form_validation', $this, $data, $errors);
+ } else {
+ $errors = $instance->type_form_validation($this, $data, $errors);
+ }
+
+ return $errors;
+ }
}
/**

0 comments on commit 84ee73e

Please sign in to comment.