[英]Form element filepicker and file manager are not displaying by $mform->addElement('filepicker' … ) Error code: noguest
[英]How to customize $mform->createElement in moodle
$attr = "onChange = alert('hi');";
$objs = array();
$objs[] =& $mform->createElement('select', $this->name.'_op', null, '',$this->get_operators(), $attr);
以上是我的代码,此处未在我的选择框中添加javascript。
实际上,穆德尔文件说第4个参数是值,第5个参数是属性,但是上面的代码第5个参数是值和属性在任何地方都不起作用。 如何自定义createElement函数。
他现在离开的另一个开发人员将moodle和php版本从5.6升级到php 7.1,现在出现此问题
贾亚维尔
您以错误的数字传递了$ attr,第5个参数是每个参数文档的属性参数https://docs.moodle.org/dev/lib/formslib.php_Form_Definition#select
从更改您的代码
$objs[] =& $mform->createElement('select', $this->name.'_op', null, '',$this->get_operators(), $attr);
至
$objs[] =& $mform->createElement('select', $this->name.'_op', null, '', $attr);
这样,您将获得有关选择框数据更改的javascript警报。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.