Skip to content
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

Would like to still show the form after submission #16

Open
bwl21 opened this issue Oct 30, 2020 · 3 comments
Open

Would like to still show the form after submission #16

bwl21 opened this issue Oct 30, 2020 · 3 comments

Comments

@bwl21
Copy link

bwl21 commented Oct 30, 2020

We are using this for feedbacks in an embedded video. If the form was submitted, it confirms the submission by showing the Text specified in the embedding element.

But how can I display the form in addition to the confirmation text such that the visitor can send another one.

@bwl21
Copy link
Author

bwl21 commented Oct 30, 2020

I tried to include the form again in the confirmation message

Ihre Meldung wurde verarbeitet.

{{insert_content::26857}}

but it appears that insert tags are not processed here.

@bwl21
Copy link
Author

bwl21 commented Nov 15, 2020

Hallo,

I had a look into the sourcecode of the page. Maybe it can be solved in the script on the frontend

  1. Add a field "successresult" (HTML-Code or Explanation (can be done by the form designer)
  2. instead of replacing the entire form, only replace "successresult" and empty the other form fields

Maybe I can even append another script which every 5 seconds replaces the conformation text with the original form ...
this is, what I will try first.

What do you think?

As a pity I have no experience with building Contao extensions, so I cannot prepare a PR.

@bwl21
Copy link
Author

bwl21 commented Nov 21, 2020

I could solve the issue by adapting the template ajaxforms.html5:

        var responsediv = form.querySelector('.ajaxformresponse');
        if (responsediv) {
            responsediv.innerHTML = "Ihre Eingaben werden versendet";
        }

        request('POST', form.action, formData, function () {
            var location = this.getResponseHeader('X-Ajax-Location');
            if (!location) {

                form.innerHTML = form.innerHTML; // clear the form fields
                var responsediv = form.querySelector('.ajaxformresponse');

                if (responsediv) {
                    responsediv.innerHTML = this.responseText;
                } else {
                    updateContent(form, this.responseText);
                }
                return;
            }

            request('GET', location, null, function () {
                updateContent(form, this.responseText, location);
            });
        });

I have to add a field in the form with the class .ajaxformresponse in which messages can be placed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant