)
好的,这是我的问题:
我试图用表单API创建表单 documentation
到目前为止一直很好,但我没有选择复制自定义表单。
$mform->addElement('header', 'newmodulefieldset', 'add time with audio and text here');
$mform->addElement('html','<div class="panel panel-default">');
$mform->addElement('text', 'time', 'time', array('size' => '64'));
$mform->addElement('text', 'audio', 'audio', array('size' => '64'));
//$mform->addElement('filepicker', 'userfile', 'audio', null, array( 'accepted_types' => '*'));
$mform->addElement('text', 'entxt', 'en text', array('size' => '64'));
$mform->addElement('text', 'fatxt', 'fa text', array('size' => '64'));
$mform->addElement('html','</div>');
$mform->addElement('button', 'another','add another one');
这是我的代码,我需要为按钮分配动作以重新创建所有这些元素。
我该怎么做?
答案 0 :(得分:2)
此功能添加重复的元素组。以零索引开头的数组索引将添加到元素名称,以便表单返回提交值的数组。
同样在表单上会有一个按钮来向表单添加额外的元素。表单页面使用额外的表单元素重新加载。这不涉及javascript。所以每次请求时,页面都会重新加载。
repeat_elements()
用例
https://docs.moodle.org/dev/lib/formslib.php_repeat_elements