Skip Navigation

[Resolved] CRED Form not sending immediately using Ajax submit

This support ticket is created 5 years, 1 month ago. 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.

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

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 9 replies, has 2 voices.

Last updated by Waqar 5 years ago.

Assisted by: Waqar.

Author
Posts
#1352561
Screenshot_2019-10-01 Responsable agence.png

Hi,

I have a CRED form that does not submit straight away when the submission button is pressed once. When you click the send button once, the field that represents the post title displays a similar message:

CRED Auto Draft a0f619f39d57600e9f77abbaefdd3aa6

When I click the submit button a second time, it sends but the page refreshes and the post title remains as the above error.

Can you advise me, please?

Thanks

Regards
Tino

#1352589
#1353797

Hi Tino,

Thank you for waiting.

During testing with a similar form and settings on my website, I was not able to reproduce this behavior, which suggests this is something specific to your website.

Do I have your permission to download the clone of your website through the already installed "Duplicator" plugin?

This way I'll be able to test this in more depth on my own server, without affecting your actual website.

regards,
Waqar

#1354005

Hi Waqar,

That's fine you can download it.

#1354957

Hi Tino,

Thank you for your permission.

While troubleshooting on your website's clone, I noticed that the "Offres Emplois" and the "Candidats" posts are connected through two different connections.

1. Through post-relationship
( WP Admin -> Toolset -> Relationships - ref: https://toolset.com/documentation/post-relationships/ )

2. A post reference field "Poste" in the "Champs Candidats" custom fields group.
( WP Admin -> Toolset -> Custom Fields - ref: https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/using-post-reference-fields-to-display-information-from-a-related-post/ )

Is there any specific reason for using two different connections between the same post types?

In the "Job Candidates Form", I noticed the following code for the selection of parent post:


  <div class="first cred-field cred-field-parent">
    [cred_field field='candidature-reference' force_type='field' class='form-control' output='bootstrap' select_text='--- Poste ---' order='ID' author='$current' value='[current-parent-id]']
    [cred_generic_field field="@candidature.parent" type="hidden" class="" urlparam=""]{"required":0, "validate_format":0, "persist":1, 
      "default":"[current-parent-id]"}[/cred_generic_field]
  </div>

I couldn't locate the definition of the custom shortcode "[current-parent-id]", but to use these relationship fields, you don't need a custom shortcode or a generic field and you can use them in the form, like this:

1. Post-relationship:


<div class="first cred-field cred-field-parent">

[cred_field field='@candidature.parent' class='form-control' output='bootstrap' select_text='--- select ---' author='$current']

</div>

2. Post reference field:


<div class="first cred-field cred-field-parent">

[cred_field field='candidature-reference' force_type='field' class='form-control' output='bootstrap' select_text='--- select ---' author='$current']

</div>

Important notes:

a). You can remove the author='$current' attribute, if you'd like to show the list of "Offres Emplois" posts added by all users and not the currently logged-in user.
( ref: https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field )

b). To pass on the current page's ID, you can use the built-in shortcode [wpv-post-id] with the value attribute.
( e.g. value='[wpv-post-id]' - ref: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-id )

I hope this helps and please let me know how it goes.

regards,
Waqar

#1355657

Hi Waqar,

Thank you for bringing to my attention the two different connections between the same post types. I have now removed the "Poste" relationship custom field and adjusted the CRED field relationship values as recommended and it does the same job.

<div class="first cred-field cred-field-parent">
    [cred_field field='@candidature.parent' force_type='field' class='form-control' output='bootstrap' select_text='--- Poste ---' order='ID' value='[wpv-post-id]']
  </div>

----------------------------------------

The issue is still the Ajax Submission for non logged in users (guests/public) which still causes the form error on the "Candidat" post title:

CRED Auto Draft ed4bf877dc934cf7a51436d247fbcf48

When you re-type the correct name and then successfully submit the form, it reloads the page even when you've got " Submit this form without reloading the page (use AJAX)" selected.

My form is a "Post form" and not a relationship form.
I was wondering if my issue relates to the following relationship forms Ajax issue:

https://toolset.com/errata/relationships-forms-in-a-views-loop-redirect-to-the-current-post-in-the-loop-when-submitted-with-ajax-and-stay-on-the-same-page-is-used/

#1356581

Hi Tino,

Thanks for sharing the update and sorry to learn that the issue still persists.

I'm going to perform some further tests with this new set up to confirm if this is the same issue or a different issue.

Thank you for your patience.

regards,
Waqar

#1357821

Hi Tino,

Thank you for waiting while I performed some tests on your website's clone.

During the investigation, I wasn't able to reproduce the issue on a new install, however, I was able to confirm that issue with forms on your website seems to happen when all these conditions are met:

- The form is set to use AJAX
- The form includes a file upload field
- A visitor is a guest ( not logged in )
- Target post is being managed by Toolset Access

I've shared these findings with the concerned team for further investigation and will keep you updated with the progress through this ticket.

Meanwhile, to keep using the form, you can use the following workaround:

1. You can set the form to submit without AJAX
OR
2. You can remove the CV field from this step (form) and collect it through a separate form, which doesn't use AJAX or which is shown only when the visitor has registered and logged-in as a user.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1358207

Hi Waqar,

I took your recommendation and stopped using the AJAX and made the page redirect to the user(child post) instead. Thank you for all your help and I hope your devs can workout this issue for non-logged in users with AJAX loading on the same page.

Regards
Tino

#1358425

Hi Tino,

You're very welcome and appreciate you brought this forward.

I'll keep you updated on this issue.

regards,
Waqar

#1372801

Hi Tino,

I'd like to update that Access 2.8.1.3 has been released, which includes a fix for this issue.

You're welcome to let us know in case the issue still persists, after updating to the latest version.

regards,
Waqar