以moodle格式显示图像

时间:2016-12-21 10:02:36

标签: php moodle

我正在使用Moodle 3.1+。我创建了一个插件来添加和编辑数据库表中的内容。现在我想在moodle表单中显示用户上传的图像。我可以在表单中添加HTML标记元素以显示图像。但问题是图像的路径是从数据库表中获取的。我怎样才能做到这一点?请帮忙。

1 个答案:

答案 0 :(得分:0)

您可能想要使用 static 元素。

$mform->addElement('static', 'elementName', 'elementLabel', $htmlcode);

$htmlCode包含您的图片代码。

要将其他数据传递给表单,必须使用构造函数的customdata参数,这是一个示例:

$form = new your_form(null, array('userid' => 2, 'foo' => 'bar'));

然后,在您的表单中,可以像这样访问:

$this->_customdata['userid']; // Contains 2.
$this->_customdata['foo']; // Contains 'bar'.