Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

219
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda