Reputation: 319
)
ok here is my problem :
im trying to create form with form API https://docs.moodle.org/dev/lib/formslib.php_Form_Definition
so far so good but i have no option to duplicate custom form.
$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');
this is my code, i need assign action to button to re create all this elements.
how can i do this ?
Upvotes: 0
Views: 1913
Reputation: 4506
This function adds a repeating group of elements. An array index starting with a zero index will be added to the elementname so that the form will return arrays of submitted values.
Also on the form there will be a button to add extra elements to the form. The form page reloads with extra form elements. This involves no javascript. SO every time you request, page will be reload.
repeat_elements()
use case
https://docs.moodle.org/dev/lib/formslib.php_repeat_elements
Upvotes: 2