Moodle表单显示错误值

时间:2015-10-14 08:16:24

标签: php mysql moodle

activity的{​​{1}} module中,我有Moodle,如果用户希望将4座位作为汽车,则会保存。它看起来像这样:

advcheckbox

一切正常,价值得到了正确保存,如果你勾选方框,你会得到有关工人的信息。然后我想改变形式,因此用户可以选择2到4座车。下拉列表,看起来像这样:

        $mform->addElement('advcheckbox', 'fourseater', get_string('fourseater', 'newmodule'));
        $mform->setDefault('fourseater', 0);
        $mform->setType('fourseater', PARAM_BOOL);

它已正确显示,但在数据库中仅保存$caroptions = array( 0 => get_string('selectcar', 'newmodule'), 1 => get_string('twoseater', 'newmodule'), 3 => get_string('fourseater', 'newmodule'), ); $mform->addElement('select', 'caroptions', get_string('caroptions', 'newmodule'), $caroptions); $mform->setDefault('caroptions', 0); 。由于我还可以选择将用户记录下载为twoseater,因此每次只保存.xls,而不是我选择的内容。以下是如何将数据提取到twoseater

.xls

在数据库中,这是表单的字段(我没有将$data[] = ($workers->fourseater == "1") ? get_string('fourseater', 'newmodule') : get_string('twoseater', 'newmodule'); 的名称更改为fourseater,因为它没有任何区别):

caroptions

我做错了什么,在我更改了<FIELD NAME="fourseater" TYPE="int" LENGTH="1" NOTNULL="false" DEFAULT="0" SEQUENCE="false"/> 之后它停止了正常工作?

1 个答案:

答案 0 :(得分:0)

你还有吗

$mform->setType('fourseater', PARAM_BOOL);

应该是

$mform->setType('fourseater', PARAM_INT);

选择的名称也是caroptions - 我猜它应该是fourseater