PageRenderTime 48ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/user/profile/index_field_form.php

https://bitbucket.org/synergylearning/campusconnect
PHP | 58 lines | 35 code | 18 blank | 5 comment | 1 complexity | 4714804f634cfa2883db81eea4d3d2e9 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-3.0, GPL-3.0, LGPL-2.1, Apache-2.0, BSD-3-Clause, AGPL-3.0
  1. <?php
  2. if (!defined('MOODLE_INTERNAL')) {
  3. die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
  4. }
  5. require_once($CFG->dirroot.'/lib/formslib.php');
  6. class field_form extends moodleform {
  7. var $field;
  8. /// Define the form
  9. function definition () {
  10. global $CFG;
  11. $mform =& $this->_form;
  12. /// Everything else is dependant on the data type
  13. $datatype = $this->_customdata;
  14. require_once($CFG->dirroot.'/user/profile/field/'.$datatype.'/define.class.php');
  15. $newfield = 'profile_define_'.$datatype;
  16. $this->field = new $newfield();
  17. $strrequired = get_string('required');
  18. /// Add some extra hidden fields
  19. $mform->addElement('hidden', 'id');
  20. $mform->setType('id', PARAM_INT);
  21. $mform->addElement('hidden', 'action', 'editfield');
  22. $mform->setType('action', PARAM_ALPHANUMEXT);
  23. $mform->addElement('hidden', 'datatype', $datatype);
  24. $mform->setType('datatype', PARAM_ALPHA);
  25. $this->field->define_form($mform);
  26. $this->add_action_buttons(true);
  27. }
  28. /// alter definition based on existing or submitted data
  29. function definition_after_data () {
  30. $mform =& $this->_form;
  31. $this->field->define_after_data($mform);
  32. }
  33. /// perform some moodle validation
  34. function validation($data, $files) {
  35. return $this->field->define_validate($data, $files);
  36. }
  37. function editors() {
  38. return $this->field->define_editors();
  39. }
  40. }