Don't pass parameters if they are empty

By: Bill Unger | Asked: 04/30/2024
ForumsCategory: General questionsDon't pass parameters if they are empty
Bill Unger asked 7 months ago
I have a simple test scenario containing first name and last name.  I have created: dataForm dataView searchForm I followed the help document to do it and all is working except... if no values are entered in either field, the dataView shows all rows.   I only want it to return results if a user has entered something in either of the fields.  If they are both blank, it shouldn't return anything. I was looking at the [if][/if] options, but they are causing more issues as I am not seeing how to combine them to show that nothing should be appended if both fields are empty.  There would also need to be additional logic to tell the line whether there should be a ? or a & or nothing 15/[if 16]fname=[16 sanitize_url=1][/if 16] [if 15]&lname=[15 sanitize_url=1][/if 15]&show_view=yes Does anyone have recommendations?
1 Answers
Bobby Clapp answered 7 months ago
If you would like to prevent entries from showing when the parameter is not set, you can add the default option to your filter like this: [get param="param_name" default="none"].

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