Skip to content

Incidencia - Encuestas - Múltiples envíos de respuesta a encuesta al accionar el botón de envío repetidamente #489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jordiSTIC opened this issue Nov 26, 2024 · 1 comment · Fixed by #490
Assignees
Labels
bug Something isn't working Encuestas not urgent

Comments

@jordiSTIC
Copy link
Collaborator

jordiSTIC commented Nov 26, 2024

Descripción del problema

En cualquier formulario de respuesta a una encuesta, se envían tantas respuestas como clics seamos capaces de hacer al submit correspondiente, antes de la redirección habitual. Visto también en suitecrm.sinergiacrm.org

Cómo reproducir el problema

  1. Crear una encuesta y hacerla pública
  2. Acceder al link de la encuesta, responderla y presionar repetidamente el botón "submit"
  3. En el crm, en la encuesta, verificar que tiene tantas respuestas como clicks hemos realizado al botón

Comportamiento esperado

No se deberían enviar múltiples respuestas

Solución propuesta

En la definición del formulario de envío de respuesta:

<form method="post">
<input type="hidden" name="entryPoint" value="surveySubmit">
<input type="hidden" name="id" value="<?= $survey->id ?>">
<input type="hidden" name="contact" value="<?= $contactId ?>">
<input type="hidden" name="tracker" value="<?= $trackerId ?>">
<?php
$questions = $survey->get_linked_beans('surveys_surveyquestions', 'SurveyQuestions');
usort(
$questions,
function ($a, $b) {
return $a->sort_order - $b->sort_order;
}
);
foreach ($questions as $question) {
displayQuestion($survey, $question);
} ?>
<button class="btn btn-primary" type="submit"><?php echo $survey->getSubmitText(); ?></button>
</form>

Deshabilitar el botón "submit" en el evento onsubmit del formulario (código a verificar):

<form method="post" onsubmit="this.querySelector('button[type="submit"]').disabled = true">
[...]
</form>

Contexto

Se presenta en todas las instancias, incluída la última versión de SuiteCRM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Encuestas not urgent
Projects
None yet
2 participants