PageRenderTime 49ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/edit_form.php

https://github.com/jacano1969/moodle-local_institutions
PHP | 76 lines | 39 code | 20 blank | 17 comment | 1 complexity | 25708d231c23cf2af76733a9e1e1cd15 MD5 | raw file
  1. <?php
  2. /**
  3. * Edit institution form
  4. * @copyright 2013 Bruno Sampaio
  5. */
  6. defined('MOODLE_INTERNAL') || die;
  7. require_once($CFG->libdir.'/formslib.php');
  8. require_once($CFG->libdir.'/completionlib.php');
  9. class institution_edit_form extends moodleform {
  10. protected $institution;
  11. protected $context;
  12. function definition() {
  13. global $USER, $CFG, $DB;
  14. $mform = $this->_form;
  15. $institution = $this->_customdata['institution']; // this contains the data of this form
  16. $context = get_context_instance(CONTEXT_SYSTEM);
  17. $this->institution = $institution;
  18. $this->context = $context;
  19. /// form definition with new course defaults
  20. //--------------------------------------------------------------------------------
  21. $mform->addElement('header','general', get_string('general', 'form'));
  22. //Fullname
  23. $mform->addElement('text', 'fullname', get_string('field-fullname', 'local_institutions'), 'maxlength="254" size="100"');
  24. $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
  25. $mform->setType('fullname', PARAM_MULTILANG);
  26. //Shortname
  27. $mform->addElement('text', 'shortname', get_string('field-shortname', 'local_institutions'), 'maxlength="9" size="10"');
  28. $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
  29. $mform->setType('shortname', PARAM_MULTILANG);
  30. //URL
  31. $mform->addElement('text', 'url', get_string('field-url', 'local_institutions'), 'maxlength="2082" size="100"');
  32. $mform->addRule('url', get_string('missingurl'), 'required', null, 'client');
  33. $mform->setType('url', PARAM_MULTILANG);
  34. //Icon
  35. $mform->addElement('text', 'icon', get_string('field-icon', 'local_institutions'), 'maxlength="2082" size="100"');
  36. $mform->addRule('icon', get_string('missingurl'), 'required', null, 'client');
  37. $mform->setType('icon', PARAM_MULTILANG);
  38. //Address
  39. $mform->addElement('text','address', get_string('field-address', 'local_institutions'),'maxlength="254" size="100"');
  40. $mform->setType('address', PARAM_MULTILANG);
  41. //Phone
  42. $mform->addElement('text','phone', get_string('field-phone', 'local_institutions'),'maxlength="49" size="20"');
  43. $mform->setType('phone', PARAM_RAW);
  44. //Description
  45. $mform->addElement('textarea','description', get_string('field-description', 'local_institutions'), 'wrap="virtual" rows="10" cols="100"');
  46. $mform->setType('description', PARAM_RAW);
  47. //--------------------------------------------------------------------------------
  48. $this->add_action_buttons();
  49. //--------------------------------------------------------------------------------
  50. $mform->addElement('hidden', 'id', null);
  51. $mform->setType('id', PARAM_INT);
  52. /// finally set the current form data
  53. //--------------------------------------------------------------------------------
  54. $this->set_data($institution);
  55. }
  56. }