Creating a search form with multiple (optional) fields

Is it possible to create a form to search a mysql db where there are multiple search fields on the form but the user can choose any of them as criteria. Not sure how to handle the empty fields in wappler ui?

ex form has 3 fields: date name location

query possible: date between first and second date and location = california (the name field is left blank on the form)

Thanks,
Rick

See https://docs.wappler.io/t/filtering-database-query-with-a-text-input/2869. Then when selecting the Conditions, add all of the relevant fields as per

thanks, i got it to work. i actually used 3 variables, one for each field. I then tried making one of the fields a date. It still works but only if all three fields have values. if only one or two of the fields have values, nothing is returned. I’m using AND for each criteria. OR doesn’t work either. Is there a specific technique required for dates?

Yes, add 3 condition groups with one rule in each of them instead 3 rules as Ben shows on his screenshot, then connect them with an AND operator.
On top of each group you see an input with a dynamic data picker. Enter an expression there, when this condition should be applied, the expression for each group will be each of your get variables. This way the condition/filter will be applied only when the get variable has a value.

1 Like

how cool!!!

It works beautifully now. Thanks so much.

Rick

1 Like