. /** * The main mod_timetable configuration form. * * @package mod_timetable * @copyright 2020 Raphael Dannecker * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot.'/course/moodleform_mod.php'); /** * Module instance settings form. * * @package mod_timetable * @copyright 2020 Raphael Dannecker * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class mod_timetable_mod_form extends moodleform_mod { /** * Defines forms elements */ public function definition() { global $CFG; $mform = $this->_form; // Adding the "general" fieldset, where all the common settings are shown. $mform->addElement('header', 'general', get_string('general', 'form')); // Adding the standard "name" field. $mform->addElement('text', 'name', get_string('timetablename', 'mod_timetable'), array('size' => '64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $mform->addHelpButton('name', 'timetablename', 'mod_timetable'); // Adding the standard "intro" and "introformat" fields. if ($CFG->branch >= 29) { $this->standard_intro_elements(); } else { $this->add_intro_editor(); } // Adding the rest of mod_timetable settings, spreading all them into this fieldset // ... or adding more fieldsets ('header' elements) if needed for better logic. $mform->addElement('static', 'label1', 'timetablesettings', get_string('timetablesettings', 'mod_timetable')); $mform->addElement('header', 'timetablefieldset', get_string('timetablefieldset', 'mod_timetable')); // Add standard elements. $this->standard_coursemodule_elements(); // Add standard buttons. $this->add_action_buttons(); } }