Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
<?php
> // This file is part of Moodle - http://moodle.org/ > // if (!defined('MOODLE_INTERNAL')) { > // Moodle is free software: you can redistribute it and/or modify die('Direct access to this script is forbidden!'); > // it under the terms of the GNU General Public License as published by } > // the Free Software Foundation, either version 3 of the License, or require_once($CFG->libdir . '/formslib.php'); > // (at your option) any later version. > // > // Moodle is distributed in the hope that it will be useful, class data_existing_preset_form extends moodleform { > // but WITHOUT ANY WARRANTY; without even the implied warranty of public function definition() { > // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the $this->_form->addElement('header', 'presets', get_string('usestandard', 'data')); > // GNU General Public License for more details. $this->_form->addHelpButton('presets', 'usestandard', 'data'); > // > // You should have received a copy of the GNU General Public License $this->_form->addElement('hidden', 'd'); > // along with Moodle. If not, see <http://www.gnu.org/licenses/>. $this->_form->setType('d', PARAM_INT); > $this->_form->addElement('hidden', 'action', 'confirmdelete'); > /** $this->_form->setType('action', PARAM_ALPHANUM); > * Database module preset forms. $delete = get_string('delete'); > * foreach ($this->_customdata['presets'] as $preset) { > * @package mod_data $this->_form->addElement('radio', 'fullname', null, ' '.$preset->description, $preset->userid.'/'.$preset->shortname); > * @copyright 2010 Sam Hemelryk } > * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later $this->_form->addElement('submit', 'importexisting', get_string('choose')); > */
< $this->_form->addElement('radio', 'fullname', null, ' '.$preset->description, $preset->userid.'/'.$preset->shortname);
> $userid = $preset instanceof \mod_data\preset ? $preset->get_userid() : $preset->userid; > $this->_form->addElement('radio', 'fullname', null, ' '.$preset->description, $userid.'/'.$preset->shortname);
}
> /** class data_import_preset_zip_form extends moodleform { > * Import preset class public function definition() { > * $this->_form->addElement('header', 'uploadpreset', get_string('fromfile', 'data')); > * $this->_form->addHelpButton('uploadpreset', 'fromfile', 'data'); > * @package mod_data > * @deprecated since 4.1 This is deprecated since MDL-75188, please use the dynamic_form $this->_form->addElement('hidden', 'd'); > * form (\mod_data\form\import_presets) $this->_form->setType('d', PARAM_INT); > * @todo MDL-75189 This will be deleted in Moodle 4.5. $this->_form->addElement('hidden', 'action', 'importzip'); > */
$this->_form->setType('action', PARAM_ALPHANUM);
> /** $this->_form->addElement('filepicker', 'importfile', get_string('chooseorupload', 'data')); > * Form definition $this->_form->addRule('importfile', null, 'required'); > * $this->_form->addElement('submit', 'uploadzip', get_string('import')); > * @return void } > * @throws coding_exception } > */
> $this->_form->addElement('hidden', 'mode', 'import'); class data_export_form extends moodleform { > $this->_form->setType('mode', PARAM_ALPHANUM);
< $this->_form->addElement('submit', 'uploadzip', get_string('import'));
> $buttons = [ > $this->_form->createElement('submit', 'submitbutton', get_string('save')), > $this->_form->createElement('cancel'), > ]; > $this->_form->addGroup($buttons, 'buttonar', '', [' '], false);
$this->_form->addElement('header', 'exportheading', get_string('exportaszip', 'data')); $this->_form->addElement('hidden', 'd'); $this->_form->setType('d', PARAM_INT); $this->_form->addElement('hidden', 'action', 'export'); $this->_form->setType('action', PARAM_ALPHANUM); $this->_form->addElement('submit', 'export', get_string('export', 'data')); } } class data_save_preset_form extends moodleform { public function definition() { $this->_form->addElement('header', 'exportheading', get_string('saveaspreset', 'data')); $this->_form->addElement('hidden', 'd'); $this->_form->setType('d', PARAM_INT); $this->_form->addElement('hidden', 'action', 'save2'); $this->_form->setType('action', PARAM_ALPHANUM); $this->_form->addElement('text', 'name', get_string('name')); $this->_form->setType('name', PARAM_FILE); $this->_form->addRule('name', null, 'required'); $this->_form->addElement('checkbox', 'overwrite', get_string('overwrite', 'data'), get_string('overrwritedesc', 'data')); $this->_form->addElement('submit', 'saveaspreset', get_string('continue')); } }