Moodle所需参数
我无法从这个错误页面出来:Moodle所需参数,moodle,Moodle,我无法从这个错误页面出来: Debug info: Error code: missingparam Stack trace: line 481 of \lib\setuplib.php: moodle_exception thrown line 548 of \lib\moodlelib.php: call to print_error() line 31 of \edit_form.php: call to required_param() edit.php: $aroleid = 72
Debug info:
Error code: missingparam
Stack trace:
line 481 of \lib\setuplib.php: moodle_exception thrown
line 548 of \lib\moodlelib.php: call to print_error()
line 31 of \edit_form.php: call to required_param()
edit.php:
$aroleid = 72; (I could get this value from database)
echo html_writer::div('<a href="'.$CFG->wwwroot.'/edit_form.php?aroleid='.$aroleid.'">'.$org->org_name.'</a>');
我可以获取参数aroleid,其中提交表单会显示此错误,并且表单不允许重定向到view.php。我被卡住了,无法跟踪问题的进展。非常感谢你的建议 提交表单时,它包括字段“roleid”和“hroleid” 默认情况下,表单提交到当前页面,但当前页面希望在加载时有一个名为“aroleid”的参数
由于您的表单不包含“aroleid”字段,因此会出现一个错误,说明缺少参数。是的,您完全正确。我没注意到这一点。我对你的祝愿,达沃斯密斯。
require('config.php');
require_once($CFG->libdir.'/formslib.php');
require_once($CFG->libdir.'/adminlib.php');
$aroleid = required_param('aroleid', PARAM_INT);
global $DB, $aroleid;
class edit_form extends moodleform
{
function definition()
{
global $DB, $aroleid;
$mform = $this->_form;
$mform->addElement('text', 'roleid');
$mform->setType('roleid', PARAM_INT);
$mform->setDefault('hroleid', $aroleid);
$this->add_action_buttons();
}
}
$mform = new edit_form();
if ($mform->is_cancelled()) {
redirect(new moodle_url('/index.php'));
}
else if ($mform->is_submitted()) {
redirect(new moodle_url('/view.php'));