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()
编辑.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>');
编辑表格.php:
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'));
我可以得到参数 aroleid,提交表单时会显示此错误,并且表单不允许重定向到 view.php。我被卡住了,无法追踪到下一个级别的问题。非常感谢您的建议。
解决方案
当您提交表单时,它包括字段“roleid”和“hroleid”。
默认情况下,表单提交到当前页面,但当前页面在加载时期望有一个名为“aroleid”的参数。
由于您的表单不包含“aroleid”字段,因此您会收到一个错误,指出缺少参数。
推荐阅读
- reactjs - 反应生命周期:阶段
- javascript - 控制器更改后,离子日期时间不会更新视图值
- python - Python的upper()方法的奇怪行为
- dart - 飞镖有运算符>>>吗?
- ios - 关闭 UIHostingController 中包含的 SwiftUI 视图
- javascript - 尝试使用 Firebase 登录时出现 403:restricted_client
- android - 滑动时 ItemTouchHelper 不更新项目
- java - 我可以让 Filter getFilter() 方法更改多个列表吗?
- java - HikariCP Spring Boot APP 使 Postgresql 连接完成
- python - 如何在我的应用程序中解决此烧瓶路由问题?