. namespace core_enrol\form; /** * Form to customise the course role names. * * @package core_enrol * @copyright 2023 Ferran Recio * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class renameroles extends \moodleform { /** * Form definition. */ public function definition() { $mform = $this->_form; $courseid = $this->_customdata['id']; $roles = $this->_customdata['roles'] ?? []; $formdata = new \stdClass(); $mform->addElement('hidden', 'id', $courseid); $mform->setType('id', PARAM_INT); foreach ($roles as $role) { $settingname = 'role_' . $role->id; $mform->addElement('text', $settingname, get_string('yourwordforx', '', $role->localname)); $mform->setType($settingname, PARAM_TEXT); $formdata->{$settingname} = $role->coursealias; } $mform->addElement('submit', 'submit', get_string('save')); $this->set_data($formdata); } }