Skip Navigation

[Resuelto] Wrong Form Being Submitted

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:

The issue here is that the user was using some custom JS to submit their form but it was targetting the wrong form.

Solution:

This was happening because they were using the generic classname for the submit button. They also had multiple forms on the page which uses the same classname.

In order to target a specific form you will need to change the form submit button class name or to target the form itself by its specific ID.

In this case we added an extra class name to the submit button.

Take a look below.
https://toolset.com/forums/topic/wrong-form-being-submitted/#post-1293155

This support ticket is created hace 5 años, 4 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Etiquetado: 

Este tema contiene 4 respuestas, tiene 2 mensajes.

Última actualización por Darryl hace 5 años, 4 meses.

Asistido por: Shane.

Autor
Mensajes
#1293081

I wanted to use a text link to submit my forms instead of the form button and found this:

https://toolset.com/forums/topic/how-can-i-turn-the-cred-submit-button-into-a-text-link/

This does exactly what I want, but I have multiple forms on the page and it always uses (submits) the last form listed.

My Template

[cred_form form="event-status-create-interested"]
[cred_form form="event-status-create-going"]

One of the Forms

[credform]
  <div style="display:none;">
    [cred_field field='post_title' class='form-control' value='[wpv-user field="display_name"]']
    [cred_field field='event-individual-intention' force_type='field' class='form-control' value='1']
    [cred_field field='@event-event-intent.parent' class='form-control' select_text='--- not set ---'  value='[wpv-post-id id='$current_page']']
  </div>
  <a href="javascript:void(0);" class="callsubmit"> <i class="far fa-calendar-star"></i> I'm Interested </a>
  [cred_field field='form_submit' output='bootstrap' value='Interested']<br/>
[/credform]
#1293127

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi Darryl,

Thank you for getting in touch.

I took a look at the code Minesh had provided and the problem with having the multiple forms on the page is that your code isn't targeting a specific form.

I would suggest giving your form's submit button a unique name and update the JS to target that specific submit button.

Thanks,
Shane

#1293141

I changed the line in my form to:

<a href="javascript:void(0);" class="callsubmitinterested"> <i class="far fa-calendar-star"></i> I'm Interested </a>

and the JS

jQuery(document).ready(function($){
   
  $('.callsubmitinterested').click(function(){
    $('.wpt-form-submit').trigger('click');
  });
   
});

(for the other form I used "callsubmitgoing" in both locations)

But the last form listed is still the one submitted.

#1293155

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi Darryl,

You need to change the name of the submit button.

Take a look at my submit button below.


	[cred_field field='form_submit' value='Submit' urlparam='' class='btn btn-primary btn-lg my-submit' output='bootstrap']

Then my code will be.


jQuery(document).ready(function($){
    
  $('.callsubmitinterested').click(function(){
    $('.my-submit').trigger('click');
  });
    
});

This will ensure that the correct form is targeted .

Thanks,
Shane

#1293159

My issue is resolved now. Thank you!