mod_form.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * The main nasatlx configuration form
  4. *
  5. * It uses the standard core Moodle formslib. For more info about them, please
  6. * visit: http://docs.moodle.org/en/Development:lib/formslib.php
  7. *
  8. * @author Leônidas O. Brandão
  9. * @version v 0.1 2019/03/04
  10. * @package mod_nasatlx
  11. * @copyright 2014 LInE - http://line.ime.usp.br
  12. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  13. */
  14. defined('MOODLE_INTERNAL') || die();
  15. require_once($CFG->dirroot.'/course/moodleform_mod.php');
  16. /**
  17. * Module instance settings form
  18. */
  19. class mod_nasatlx_mod_form extends moodleform_mod {
  20. /**
  21. * Defines forms elements
  22. */
  23. public function definition() {
  24. $mform = $this->_form;
  25. //-------------------------------------------------------------------------------
  26. // Adding the "general" fieldset, where all the common settings are showed
  27. $mform->addElement('header', 'general', get_string('general', 'form'));
  28. // Adding the standard "name" field
  29. $mform->addElement('text', 'name', get_string('nasatlxname', 'nasatlx'), array('size'=>'64'));
  30. if (!empty($CFG->formatstringstriptags)) {
  31. $mform->setType('name', PARAM_TEXT);
  32. } else {
  33. $mform->setType('name', PARAM_CLEAN);
  34. }
  35. $mform->addRule('name', null, 'required', null, 'client');
  36. $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
  37. $mform->addHelpButton('name', 'nasatlxname', 'nasatlx');
  38. // Adding the standard "intro" and "introformat" fields
  39. //Moodle 2: $this->add_intro_editor();
  40. $this->standard_intro_elements(); //Moodle 3
  41. //-------------------------------------------------------------------------------
  42. // Adding the rest of nasatlx settings, spreeading all them into this fieldset
  43. // or adding more fieldsets ('header' elements) if needed for better logic
  44. $mform->addElement('static', 'label1', 'nasatlxsetting1', 'Your nasatlx fields go here. Replace me!');
  45. $mform->addElement('header', 'nasatlxfieldset', get_string('nasatlxfieldset', 'nasatlx'));
  46. $mform->addElement('static', 'label2', 'nasatlxsetting2', 'Your nasatlx fields go here. Replace me!');
  47. //-------------------------------------------------------------------------------
  48. // add standard elements, common to all modules
  49. $this->standard_coursemodule_elements();
  50. //-------------------------------------------------------------------------------
  51. // add standard buttons, common to all modules
  52. $this->add_action_buttons();
  53. }
  54. }