Skip Navigation

[Resolved] Relationship form "Submit button" issue

This support ticket is created 3 years 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.

Our next available supporter will start replying to tickets in about 2.25 hours from now. Thank you for your understanding.

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: Africa/Casablanca (GMT+00:00)

This topic contains 4 replies, has 3 voices.

Last updated by Jamal 3 years ago.

Assisted by: Jamal.

Author
Posts
#2013257

Hello,

There are some relationships forms on the site with the following issue

1) When click on the "Submit button" nothing happens, so I need to click twice

2) After the second click, I get the message "These two elements are already associated and the relationship does not allow non-distinct associations" (and then create the connection as normal) but there were no associations before because I have a view previous that shows the relationships and it says "No items found" and after it shows the created connection. You can see it here before hidden link and after hidden link for this CPT but I found the same issue in other relationship forms on the site.

Thanks

#2013465

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

It sounds like the relationship form does submit on the first click (hence, when clicking a second time it says the posts are already connected), but that there is no feedback to indicate the form has been submitted.

Can you review the settings for your form, what is expected to happen after submitting the form? Can you check an alternative setting and report what you find?

#2013471

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

A quick update: I checked on a local test site, and saw something similar if the form is set to reload the page after submission, but the form is also set to submit via ajax.

When submitting via ajax the page doesn't reload, but that combination of settings doesn't actually make much sense.

If you want to reload the page, disable the ajax option.

Then the page should reload, and the form values will be cleared.

#2016341

Hello,

Thanks for point the solution to the issue, it worked. The first click created the link with ajax and the second try to do and then reload. So I just uncheck the ajax and now it works with the first click

The usability here is that as I don't use ajax, the page goes up after reload and the user loses focus on the form.

Do you have a workaround solution similar to update a container with ajax (the view) after submitting the form with ajax? I would like to see the view updated (with the connection the user has just created with the submit) without reload the entire page. hidden link

Thanks

#2016941

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Toolset Forms offers the cred_success_redirect filter to change the redirect URL of a form on success. You can append a hash fragment in the URL to scroll to that specific section of the page. Something like hidden link will scroll to the element with id="task-courses"
https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect

Unfortunately, Toolset Forms does not have a proper Javascript API. Otherwise, we could trigger a search on the view and make it update itself using AJAX. If you need an API, please suggest it on this page https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

Without proper API from Toolset Forms, you will need to come up with a hacky solution, which will depend on your use case(theme, HTML markup, etc.) Check this article about intercepting AJAX requests: hidden link

You can create your custom ajaxSetup and hide the spinner whenever an AJAX call is ended. You may need to do some checks to determine if the AJAX call is coming from that specific form.

jQuery(function($){
    $.ajaxSetup({
         beforeSend: function (xhr) {
              // your code here
          },
          complete: function (xhr,status) {
            // your code here
        }
    })
})

If you manage to get the form response, you may trigger an AJAX search on the view. Add search box and submit button to the view's search section. Hide the view's filters using CSS. Trigger a click on the submit button when the form completes successfully.

Please note, that custom code is beyond the scope of the support forum, If you are not comfortable with programming, consider hiring a developer or one of our partners https://toolset.com/contractors/

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.