Support

Account

Home Forums Backend Issues (wp-admin) Populate select list with contents from another select list in admin

Solving

Populate select list with contents from another select list in admin

  • I hope this is possible. Note this is all admin side.

    I have a Page that has two Custom Field Groups attached to it (ACF Pro). The first one is a simple repeater with two sub-fields categoryName and categoryURL. I have entered a small set of data rows into these fields. These are never meant to be rendered to front-facing pages.

    The second Custom Field Group is a sponsorship list repeater with many subfields, one of them being sponCategory. It is a select list. I want to populate that select list with the contents of the data entered into the aforementioned Custom Field Group that is on the same page. This will allow other admins to quickly enter data, being able to pick the category in question from the master list rather than typing it in every time.

    Can I do this?

    (Also, I am a registered full ACF Pro user under username [email protected], but for some reason I registered support here under this userid [email protected] (personal email), and no matter how I try, no email shows up when I attempt to register for support forums on the former email address, which is the address associated with my purchases — just trying to explain that I am a registered user.)

  • Hi @blakespot

    You can use the acf/load_field hook to do that, but you need to save the post and the first repeater field first before it showing up on the second repeater field. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/.

    If you don’t want to save the post first, you need to use advanced Javascript code to achieve it. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/. I believe you can use the acf.add_action('append', function( $el ){ action to check the new row in the second repeater and then update it with the data from the first repeater.

    I hope this helps 🙂

  • James,

    I saw this page and attempted to get this done using it as a guide but was unsuccessful and so determined it may not be possible. This is why I posted to the forums.

    Must the options page be the source on this? I’d rather it not be.

    Thanks.

  • Hi @blakespot

    Could you please share the code you’ve tried and let me know the issue with that code? Also, could you please share the JSON or XML export file of the field group?

    Please keep in mind that I can only help you with a simple customization. If you need advanced customization, I suggest you hire a developer to help you out with it, and I’d recommend looking for one on https://studio.envato.com/, https://www.upwork.com/, or https://codeable.io/.

    Thanks 🙂

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

The topic ‘Populate select list with contents from another select list in admin’ is closed to new replies.