Forums › Forums › Search & Filter Pro › Hide Dropdown choice of ACF Post meta Fields with no data
Tagged: acf
- This topic has 2 replies, 2 voices, and was last updated 6 years, 7 months ago by Anonymous.
-
Anonymous(Private) May 2, 2018 at 5:13 am #175259
Hi,
Loving the plugin, its quite impressive.
We have a question, we are wondering if we can hide dropdown choices for ACF fields.
We have a field that is the width of a house (so 11m, 12m, 13m etc).
Because we are using a dropdown and showing with Range, on the front end, the user sees Ranges from the smallest to the largest we have used, even if there are no selectable options (ie, no houses from 12-14).How do we hide the dropdown choices that have no selectable choices?
Thanks!
Trevor(Private) May 2, 2018 at 10:15 am #175293It would require some custom javascript on your part. I am sorry, but I do not have a snippet to share with you, but you might find something suitable to guide you on StackExchange.
The script needs to look at the select(s) and determine if there are any options, and if not, hide the select, or if it has, reveal the select (just in case it was previously hidden).
Before doing this, you would also need, in the form settings, on the General settings tab, to:
Set
Auto Count
(both settings) toON
And then in the Form UI:
In each field set
Hide Empty
toON
Then, your javascript needs to be written as a function, to be called at three possible times:
1. When the document has loaded (the page).
2. When our Auto Count is triggered:<script>(function ( $ ) { "use strict"; $(document).on("sf:ajaxformfinish", ".searchandfilter", function(){ console.log("ajax complete"); // call your function or here }); }(jQuery));</script>
2. When our Ajax is triggered:
<script>(function ( $ ) { "use strict"; $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ console.log("ajax complete"); // call your function here }); }(jQuery));</script>
-
AuthorPosts