acf-dynamic-ajax-select-example
acf-dynamic-ajax-select-example copied to clipboard
Field keys don't match json
In dynamic-text-based-on-user-select's js:
// this data-key must match the field key for the user field on the post page where // you want to dynamically load additional user information 'change [data-key="field_57ab9d5905e4f"] input': '_update_user_fields', // this entry is to cause the city field to be updated when the page is loaded 'ready [data-key="field_57ab9d5905e4f"] input': '_update_user_fields'
The first key isn't found in the example json. The 2nd one is in the json, but it's the user field. Difficult to understand how this code works.
The only place you will find the any keys is in this action. These actions cause the function to run that does the updates.
The other keys are located in the PHP file. The AJAX function returns the fields keys to be updated as part of the response array. See the function at line 50 of the PHP file in the example.