Problem when i run search form

By: Chris Harrison | Asked: 02/25/2023
ForumsCategory: General questionsProblem when i run search form
Chris Harrison asked 1 year ago
  I create the search form and i combined with the view, but when i press search button  i always get the answer  "No Entries Found" till i refresh the page.. Then i get the filtered values view.  
2 Answers
Walter JonesWalter Jones answered 1 year ago
Is your form being submitted with Ajax?  If so turn that off.
Chris Harrison replied 1 year ago

No is already off

Victor Font answered 1 year ago
In order for a search to work, a SQL query must execute on your server to return the result set for the view. This means that before you hit submit, views will always show "No entries found" until the search query is executed on the server. To see the result, you must refresh the page. The way to prevent seeing "No entries found" is to use two pages for your search. The first page only has the search form. When you submit the search criteria, the search form redirects to the second page that has both the search form and view. You'll only see filtered results this way provided you've created the filter properly in the view.
Chris Harrison replied 1 year ago

Why to create 2 pages ?
So far i was working perfect with just one page?

Can you give me a solution to have one page pls.

Victor Font replied 1 year ago

You can certainly use one page, but you'll need to write custom code. I shared with you what has become a best practice, because many Formidable users may not have the skill yet to develop the custom code required to use one page, but that doesn't seem to be an issue for you. Here's what you have to do:

Hide the view with CSS before the search form submits, and display the view with CSS after the search form runs. This means you have to develop code to track the form's state. You could use browser storage to do this.

You can also use browser storage to save/restore the search criteria so users don't have to re-enter their selections after a page refresh. This is what I do with the search for the Formidable Masterminds Developer Directory:

Chris Harrison replied 1 year ago

I fix the problem
Now it works as before, perfect i can say
And All in one page


Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community