search field accepting multiple entries i.e. SEARCH FIELD will accept CITY, STATE AND/OR ZIP

By: Sergio Henriquez | Asked: 05/19/2023
ForumsCategory: General questionssearch field accepting multiple entries i.e. SEARCH FIELD will accept CITY, STATE AND/OR ZIP
Sergio Henriquez asked 1 year ago
Hi everyone, I have built a search form for my webpage. These search fields work just fine if applied in single, separate form i.e. If I look for KEYWORKD, CITY, STATE, ZIP, there is a search field for each and everyone of these search criterias.

I have seen similar search forms/fields in other web sites where the query can be placed in a single entry field. For example, if I am looking for 

JOB NAME, OR SKILL (one search field) or  CITY, STATE, ZIP (one search field)   has anyone accomplished this functionality already. FF supports said it is not supported, eventhough I think this may be rather easy to accomplish Any ideas or suggestions, I would really appreciate it Sergio  
3 Answers
Rob LeVineRob LeVine answered 1 year ago

I'm a little surprised you were told that it's not supported because it seems relatively simple to do in two ways:

  1. Have your view use the same keyword for all three fields, e.g., let's say your URL is https://your.com/search-page?search1=xxx&search2==yyy  then in your view you set all three fields, city, state and zip to be " like " [get param="search2"] and the same for the job name and skill, using search1.
  2. Create hidden fields that are text concatenations of the fields you're combining, e.g,. job-skill and then, in your view, your filter criteria uses the hidden fields and then you set those two filter fields to be "like " get[param="search1"], etc. just like the first option.

I can't say for sure either will work, but it seems worth trying.

Sergio Henriquez replied 1 year ago

<p>Hi Rob, thanks for your feedback, I really appreciate your time and interest. I am not quite sure I understand WAY-1. Would it be too much to ask you to elaborate a little more, please?</p><p>I am attaching a visual. sometimes one photo can say 1000 words... See pdf attached please.</p><p> </p><p> </p>

Rob LeVineRob LeVine replied 1 year ago

My #1 suggestion is to use the exact same stuff you used to do the form/view you have now, just using the same value for all three filters in your view. For example, currently, you must have a filter for city that look like "City like [get param="city"]" or something like that. I'm suggesting you use the same param for all three pieces, city, state and zip.

Sergio Henriquez replied 1 year ago

Hi Rob, oh yes. I get it, and I have tried it. It should be reverse of what you're saying, in the sense use the [get param="city", "state", "zip"] but his construct won't work.

if I want either of the 3 criterias above, I need to tell the search field what it should look for. My problem is how to do a multiple search criteria entry for one single field.

Thanks so much Rob, I really appreciate your input. I will let you know once I resolve it.

Cheers,
Sergio

Rob LeVineRob LeVine replied 1 year ago

Now I just have to know what you're trying to accomplish. I'm lost at this point. Can you send a screenshot of your filter screen and send a simple use case, e.g., User goes to search page, types in xxx in field(s) x, y, z and searches in hopes of finding yyy?

Sergio Henriquez replied 1 year ago

Good morning Rob,
in my previous message, I failed to provide a screen shot of the view filters. Please see attachment. Let me know if you have any questions.

Cheers,
Sergio

Sergio Henriquez answered 1 year ago
Hi Rob, 
see attached PDF document for better understanding.   Cheers, Sergio
Attachments
Victor Font replied 1 year ago

That's a nicely written document, but I don't understand why you are using parameters as default values in the search form. Search form values are passed as parameters to your view filters in a submit redirect. Rob was asking you for a screen print of the view filters. Your document explains what you want to accomplish. This is my response to what I understand you want to achieve.

You want to concatenate three fields for display and use the single concatenated field to search the database. It is possible to do this, but it cannot be done without custom code and the reason may surprise you. It has to do with the metadata schema. Formidable follows the same metadata schema principles as WordPress designed. This means every field in a form entry has its own row in the frm_item_metas table. Entry header records are in frm_items. From a database perspective this is a one-to-many relational design. To execute a search query against this type of deign requires a LEFT JOIN for each meta_data parameter passed to the view filter. Here's where you can learn more about the schema: https://formidableforms.com/knowledgebase/database-schema/.

Every populated field in a search query must match a field in the database to return records. While displaying 3-separate fields in a single drop down is a piece of cake through frm_setup_new_fields_vars, searching requires splitting those values up before feeding them to your query. This requires custom code.

The alternative is to create a hidden field to store the concatenated values on the entry form, which you can formularize as a default value for the hidden field. You can then use the concatenated values for display on your search form and as a filter for a view.

Sergio Henriquez replied 1 year ago

Hi Victor,
thanks for your input. it may be that my sought solution requires custom development.
Also for pointing out, that Rob was asking for the view filters which I failed to provide.

I am not a developer, so I will have to look for such a help in the FF community.

I will review your comments carefully to see if I can see the light...

Cheers,
Sergio

Sergio Henriquez answered 1 year ago
Good morning Rob,
in my previous message, I failed to provide a screen shot of the view filters. Please see attachment. Let me know if you have any questions. Cheers,
Sergio
Attachments
Rob LeVineRob LeVine replied 1 year ago

From the screenshots and URL as an example, I now see why you can't do the address part as either Victor or I described. It looks like you want a Geolocation-type field for that and I don't see that as being possible for an out-of-box usage with Formidable. I can only see handling that via jQuery (and maybe ajax). You might wish to write up a clear and concise description of your need and shop it around to the Formidable Masterminds - https://formidable-masterminds.com/developers-directory/

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
crossarrow-right