Hube2 / acf-dynamic-ajax-select-example

Examples of dynamically loading values with AJAX based on other fields
182 stars 56 forks source link

Use within repeater #7

Open solech1 opened 6 years ago

solech1 commented 6 years ago

Many thanks for this script! Any one able to help with adapting this to work exactly as is, but in a repeater field. So, in the "Post" post type, you can have both the state select field and the city select field in a sub-field then repeated.

Any help very much appreciated!

Hube2 commented 6 years ago

When working with repeater fields, what you need to do is figure out what row you working on and then adjust base on that.

For example, get the row of the current field var $row = e.$el.closest('.acf-row'); the you need to find the other field in the same row. var $select = $row.find('[data-key="field_5793770922131"] select');

solech1 commented 6 years ago

Awesome, thanks!

solech1 commented 6 years ago

Hi @Hube2, sorry to resurrect this thread. Any idea why this wouldn't save? The solution above works for populating the select within the repeater, but wouldn't save. Many thanks!