Support

Account

Home Forums General Issues insert value of a custom field, based on another custom field

Solving

insert value of a custom field, based on another custom field

  • Here is what I setup.
    1. Created 2 CPTs: providers and goods.
    2. Using ACF for creating a field group (List of providers) which includes several fields:
    – Provider name.
    – Address.
    – Email…

    Location: Post type = providers.
    3. Adding some providers.

    4. Using ACF for creating another field group, which includes the below fields:
    – Name
    – Provider: using Post Object, Filter by Post Type: providers.
    – Provider address.
    – Provider email.

    Location: Post type = goods.

    5. And now what I would like to work when adding a new good.
    – Entering the name.
    – When I choose one provider, the provider address and provider email fields automatically being filled with the information, which I already saved before in step 3.
    – If I change to another provider, the Provider address and Provider email fields will be also updated correspondingly.

    Is this possible?

  • Did you get an answer to your question?

    I have a similar construction (pun intended). I develop sites for builders and have a FLOORPLANS Custom Field Group with fields liked Bedrooms QTY, Bathrooms QTY, Square Feet, Price, etc. I also have a HOMES field group with Floorplans populated with the namefrom the other field group via Post Options but I would also like to bring over Bedrooms, Baths, etc. from FLOORPLANS. Essentially a clone of the values from FLOORPLANS and then let the user customize the values if necessary.

  • No, I don’t have any answer for this, unfortunately.

  • I have an example of doing this with a relationship field, unfortunately, it has not been updated to work with the new ACF JS API and will not work in the current version of ACF.

    What you have to do is to add an action on the relationship/post object field that triggers an AJAX request to get and populate the values in the other fields. As I said, this old example will not work, but it covers the basics https://github.com/Hube2/acf-dynamic-ajax-select-example/tree/master/dynamic-fields-on-relationship

    This example has been updated to work with the current version of ACF and shows the differences from the old code to the new code when it comes to making the AJAX request https://github.com/Hube2/acf-dynamic-ajax-select-example/tree/master/dynamic-select-example

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

The topic ‘insert value of a custom field, based on another custom field’ is closed to new replies.