I added a drop down list in the Question Editing form
by the following code in the definition()
function of edit_question_form.php
:
我在问题编辑表单中添加了一个下拉列表,它是由edit_question_form.php的定义()函数中的以下代码编写的。
$mform -> addElement('select', 'qtype', 'Choose type', array('optionOne' => 'Value Option One', 'optionTwo' => 'Value Option Two', 'optionThree' => 'valueOptionThree'), array('id'=>'id_dropdown'));
$mform->addRule('qtype', get_string('error'), 'required', 'server'(default), false, false);
And the action of this form points to question.php, so in question.php, I added the following statement:
而这一形式的作用指向了一个问题。php,所以在问题。php,我添加了以下语句:
$qtypeq = required_param('qtype', PARAM_TEXT);
But I get the following error:
但我有以下错误:
A required parameter (qtype) was missing
缺少一个必需的参数(qtype)。
Aparently it is not missing.
很明显,它没有失踪。
So can anybody suggest why am I getting this error and what can I do to fix it?
有人会说为什么我犯了这个错误,我该怎么做才能解决它?
1 个解决方案
#1
2
The first step I'd take would be to open up the developer tools in my browser, switch to the 'network' tab, then check exactly what params are sent when the form is submitted.
我将采取的第一步是在浏览器中打开开发工具,切换到“网络”选项卡,然后在提交表单时检查发送的是哪些参数。
If the 'qtype' param is definitely there at that point, then the next step would be to add a 'var_dump($_REQUEST);' immediately before the 'required_param' line (this will output every param that has been sent to the page via get or post).
如果“qtype”param在这一点上是肯定的,那么下一步就是添加一个“var_dump($_REQUEST)”,在“required_param”行之前(这将输出通过get或post发送到页面的每个param)。
If that doesn't shed any light on what is happening, then the next thing to do would be to install xdebug and configure your IDE to work with it. You can then stick a breakpoint on the 'required_param' line and step through it and see exactly what is going wrong (as an aside, even if you don't need it this time, install xdebug anyway, as it will help a lot in the future).
如果这不能说明正在发生的事情,那么接下来要做的事情就是安装xdebug并配置您的IDE来处理它。然后,您可以在“required_param”行上粘贴一个断点,并通过它来查看到底发生了什么错误(顺便说一下,即使您现在不需要它,还是安装xdebug,因为它在将来会有很大帮助)。
#1
2
The first step I'd take would be to open up the developer tools in my browser, switch to the 'network' tab, then check exactly what params are sent when the form is submitted.
我将采取的第一步是在浏览器中打开开发工具,切换到“网络”选项卡,然后在提交表单时检查发送的是哪些参数。
If the 'qtype' param is definitely there at that point, then the next step would be to add a 'var_dump($_REQUEST);' immediately before the 'required_param' line (this will output every param that has been sent to the page via get or post).
如果“qtype”param在这一点上是肯定的,那么下一步就是添加一个“var_dump($_REQUEST)”,在“required_param”行之前(这将输出通过get或post发送到页面的每个param)。
If that doesn't shed any light on what is happening, then the next thing to do would be to install xdebug and configure your IDE to work with it. You can then stick a breakpoint on the 'required_param' line and step through it and see exactly what is going wrong (as an aside, even if you don't need it this time, install xdebug anyway, as it will help a lot in the future).
如果这不能说明正在发生的事情,那么接下来要做的事情就是安装xdebug并配置您的IDE来处理它。然后,您可以在“required_param”行上粘贴一个断点,并通过它来查看到底发生了什么错误(顺便说一下,即使您现在不需要它,还是安装xdebug,因为它在将来会有很大帮助)。