Support

Account

Home Forums Pre-purchase Questions External search Reply To: External search

  • I cannot give you any code except for a few snippets, but it is possible.

    First you create select field with the following options

    Choices = dynamically generated
    Stylized UI = Yes
    Use AJAX to lazy load choices = Yes

    Create an acf/prepre_field filter to dynamically generate the choices. The reason why we do this on acf/prepare_field is so that the choices are only loaded when used. Connect to your external DB and populate the choices from there.

    Create an acf/load_field filter for the same field. This filter should only run during AJAX requests. At the top of the function add:

    
    if (!defined('DOING_AJAX') || !DOING_AJAX) {
      return $field;
    }
    

    Other than this it does the same thing that the first function does and you can just call that function and return what it returns.

    And then create and acf/format_value filter that will use the selected value to get what you need from the external DB and format it in whatever way it needs to be formatted.

    There may be other ways to do this, but I had to do something similar. The main difference was I was not connecting to an external DB.