Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

218
Views
How to submit form without ID in PHP oops

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);
  1. Firstly, I'm confused, button and form both are located in different locations nevertheless they are connected how?
  2. So I can't use the form id in the button's file.

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!