Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

220
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda