Support

Account

Home Forums Add-ons Repeater Field Nest existing repeater inside new repeater, retaining field values

Solved

Nest existing repeater inside new repeater, retaining field values

  • I have an existing repeater field with sub fields. I have already filled out many rows in this repeater but now need to make this repeater live inside another repeater that I am going to create. I know how to nest repeaters but in this case, I need to retain all the info I already entered so I don’t have to re-enter it. Any way to do this?

  • Hi @moettinger

    That’s a tough one.Sub field values are saved to wp_postmeta etc. in this way: repeater_field_name_0_sub_field_name with 0 ticking upwards with each row.

    With an repeater inside another repeater I think it’ll be:
    repeater_field_name_0_sub_repeater_field_name_0_sub_field_name

    Since you now initially want to put your repeater in another repeater I’m assuming the whole current repeater should go as the first row (I.E. 0).
    You’d probably have to do some clever SQL queries to change the values of each repeater_field_name_0_sub_field_name into repeater_field_name_0_sub_repeater_field_name_0_sub_field_name

    but you’ll also first have to make sure atleast 1 row has been previously created in the root repeater. If you check the DB you’ll see that the repeater fields only contain a count (starting at 1) of how many rows they contain so just running an SQL for the above will not cause the values to show up.

    Hope I got you started! It’s not an easy topic to tackle 🙂

  • Makes sense and I’ll try this exact suggestion. Thanks!

  • No problem!

    Glad I could help you on your way. Just post here if you need more help or feedback!

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

You must be logged in to reply to this topic.