I'm new in Moodle development I'm stuck in Moodle form submission.
Mustache Template Code
<button type="button" onclick="request_access(this)" id="{{ data }}"
class="btn btn-primary col mr-1" data-action="save">
{{#str}} savechanges {{/str}}</button>
Form created in PHP
$editorhtml = '';
$editor = editors_get_preferred_editor();
$editor->use_editor("usernotes", array('autosave' => false));
$editorhtml .= html_writer::start_tag('div', array('class' => 'ltoolusernotes'));
$editorhtml .= html_writer::start_tag('form', array('method' => 'post', 'action' => $args['pageurl'], 'id' => 'notes-from', 'class' => 'mform'));
$editorhtml .= html_writer::tag(
'textarea',
'',
array('id' => "usernotes", 'name' => 'ltnoteeditor', 'class' => 'form-group', 'rows' => 20, 'cols' => 100)
);
$editorhtml .= html_writer::tag('input', '', array(
'type' => 'hidden',
'name' => 'course',
'value' => $args['course'],
));
$editorhtml .= html_writer::tag('input', '', array(
'type' => 'hidden',
'name' => 'contextid',
'value' => $args['contextid'],
));
$editorhtml .= html_writer::tag('input', '', array(
'type' => 'hidden',
'name' => 'contextlevel',
'value' => $args['contextlevel'],
));
$editorhtml .= html_writer::tag('input', '', array(
'type' => 'hidden',
'name' => 'pagetype',
'value' => $args['pagetype'],
));
$editorhtml .= html_writer::tag('input', '', array(
'type' => 'hidden',
'name' => 'pagetitle',
'value' => $args['pagetitle'],
));
$editorhtml .= html_writer::tag('input', '', array(
'type' => 'hidden',
'name' => 'pageurl',
'value' => $args['pageurl'],
));
$editorhtml .= html_writer::tag('input', '', array(
'type' => 'hidden',
'name' => 'user',
'value' => $args['user'],
));
$editorhtml .= html_writer::end_tag('form');
$editorhtml .= html_writer::end_tag('div');
$editorhtml .= ltool_note_load_context_notes($args);
I have tried a solution which is reload()(event) the page on reload data submit but sometimes reload event is fired before the form submission. so data can't submit.
what is the solution? I want to solve it using JS.