Search Form Flexability

bespokeappstt

Hubstaff freelancer
I have a search form with several dropdown boxes. The problem is that I don't want the user to select every dropdown box to get a result. If they choose only one dropdown out of 4 then the search or query on the list should be based on that one option alone and the rest should be like a generic 'ALL'. So if there are 2 dropdown boxes and one allows you to choose a country and the other a profession but you only choose a profession, then the query should search for that profession in All countries. How do I do this?
 
I am using a search form that has 3 dropdown menus. I want a search to be conducted based on any one or combination of all. In the screenshot I am conducting a search based only on the 'Profession' field. So I want value of the other two fields to be 'all' in the sql query. As a result the value for those default text are %. Based on the search results I think the datetime is being included in the search. I do not know how that got there, how can I remove it? It's not one of the elements in the search form so I don't know why it's turning up in the results filter. First I want to know how to remove this datetime and secondly, my approach using the '%' for the value of the default text. Will it be the equivalent of using the sql all(%)? If not how do I get that done.
 

Attachments

  • searchForm1.png
    searchForm1.png
    144.8 KB · Views: 165
  • searchResults1.png
    searchResults1.png
    10.5 KB · Views: 167
Sorry about the slowness here, I've been a bit busy.

I'm having to set up a test case to see what the issue is.

-- hugh
 
On the search form, assuming it's a tableless form, remove the datetime element.

I'm seeing the results I'd expect from checkbox filters, if I remove the date_time element that erroneously gets created (a result of the new 'content types' stuff we added recently).

-- hugh
 
It is tableless I used this tutorial to build it,
http://fabrikar.com/help/tutorials/details/3/26-creating-a-search-form
I have removed the datetime element and it's still not working. I hope this can be resolved soon. I did a test however and noticed that if I unpublish the other two elements(industry and country) and leave the 'Profession' dropdown it works. Which means my little trick of putting '%' as the value for the default text hoping that it translates into 'where industry is like % and country is like %' is not getting that translation. Another idea would be to leave out the other 2 elements entirely from the sql predicate and only 'Profession' is in the Where clause. I think this is where the problem lies. I'm now wondering if that can be done, any dropdown box that is not selected or whose value is '%' is left out of the search string entirely. Can someone solve this for me please.
 
Last edited:
Ah, sorry, I see the issue now. or some reason I had "checkbox" on the brain.

Yes, so the problem is ... our search form filter logic will ignore the input if it is an empty string, but you can't set a dropdown option to empty. And you can't use % because we automatically escape %'s in values, explicitly to prevent them from acting as wildcards.

I'm testing a solution, which is to simply remove that restriction on dropdown values, so you can set add an "All" option to your search form dropdowns, which an empty value, which then skips adding that as a filter.

It's working for me, I just need to make sure there's no nasty side effects before committing it to github.

-- hugh
 
So just add the code to the administrator/components/com_fabrik/models/fields/suboptions.js? Not to sure on how to proceed to achieve the desired effect?
 
Okay I now get it. Blank label but ALL as the value. But have you tried it on mysite? The search results still turn up blank. So you can put 'ALL' in the value field with a blank label but the actual search is not working on the frontend.
 
You should do a complete GitHub update (backup before).

Clear Joomla and browser cache so you won't run JS code in cache.

It's the value which must be blank, the label does not matter, you can use ALL or whatever you want.
 
If I leave the value blank it does not allow me to save.
 

Attachments

  • cantSave.png
    cantSave.png
    69.1 KB · Views: 158
Last edited:
If I however leave the label blank but put 'ALL' for the value then i can save and the 'All' is reflected on the front end.
 

Attachments

  • cantSave2.png
    cantSave2.png
    158.1 KB · Views: 160
  • cantSave3.png
    cantSave3.png
    121.1 KB · Views: 151
Full GitHub update: WIKI: Update from GitHub

If you've only added the patch manually (not recommended at all, but may be working in this case) you have to make sure that in Fabrik Options/Debugging you've set "Allow fabrikDebug" = DebugJS.
Otherwise it's running the unchanged minified JS file.

I tested, it's working on my site: value blank, label whatever
 
I've taken out Professional Support. I've backed up using Akeeba. Can someone sort this out for me? It's the reason why I took out support. I have changed the debugging in the options and it still does not work for me. I cannot save if the value is blank.
 
You are definitively running the unmodified administrator/components/com_fabrik/models/fields/suboptions.js file
Are my issues related to not doing a full update?
What did you do? There's no modification at all, your code is still

upload_2016-2-22_18-49-31.png
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top