I am trying to:
Submit a contact form and have it refresh with a message (or just the same form stays displayed).
Link to a page where the issue can be seen:
hidden link
I expected to see:
After submitting the form, I expected to see a "thanks" message. The page should be refreshed and no scrolling should happen.
Instead, I got:
The "thanks" message but the page scrolls down a bit, I think to the top of the cred form perhaps. The URL ends up like this:
hidden link
Could it be due to the #cred_form_70_1 in the URL? Why is that there?
Dear brentC,
You are right, it is due to the #cred_form_70_1 in the URL, that is a HTML anchor:
hidden link
So when you submit the CRED form successfully, the browser will be able to scroll to the CRED form location.
Is it possible to prevent this behavior?
I have a CSS fixed header panel at the top of my site (which is probably a common thing) and so when it scrolls the actual "thanks for contacting us" message gets hidden behind the panel... This happens on pages where there is lots of text below the form so scrolling is possible (note: this only happens when logged in so you can't easily see it on the example link but it happens for me and you can probably imagine how that would happen on any site with lots of content below the form).
I thought of using the "redirect to another page" option to solve this but my site is in two languages so I can't easily pick a static page. I also tried the "AJAX submission" but it still redirects afterward. I also tried "keep displaying this form" and same issue. Is there any way to cleanly resolve this?
There isn't such a built-in feature within CRED form, if you agree, we can take it as a feature request, our developers will evaluate it.
Yes, definitely a feature request please.
Any ideas on the best way to deal with this in the meantime? It is a really weird experience right now... Worst case I'd have to duplicate the form and specify a specific redirect page for each language in my two-language site.
Or, I guess I could redirect them to the submitted post with a "thank" message at the top of that page, but I didn't really want to make the post public (although I guess if I could make the URL something random like a GUID that might be ok - security through obscurity).
The HTML anchor is added in CRED plugin file cred-frontend-editor\application\models\form\post.php, line 117:
$url = $url . '#cred_form_' . $prg_id;
You can simply commend it to:
//$url = $url . '#cred_form_' . $prg_id;
Ok, thanks, but that would get overwritten on the next update of CRED, right? Any way to do it in a more maintainable way?
Yes, it will be overwritten, it is only a temporary workaround.
As I mentioned above there isn't such a built-in feature within CRED form
https://toolset.com/forums/topic/after-submitting-page-scrolls-down-to-form-top/#post-594222
And I have filed it as a feature request, our developers will evaluate it.