Forums Forums Search & Filter Pro Hide Dropdown choice of ACF Post meta Fields with no data

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Anonymous
    #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
    #175293

    It 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) to ON

    And then in the Form UI:

    In each field set Hide Empty to ON

    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>
    Anonymous
    #175511

    Thanks for that, greatly aprpeciated, we will see what we can do.

Viewing 3 posts - 1 through 3 (of 3 total)