How to save repeater fields in the options page?

I am trying to save the option for a two repeatable select fields
I am using this class method to create the options page and fields (Example #2): https://codex.wordpress.org/Creating_Options_Pages

The field is like below in the callback function.

Javacript library used : https://github.com/DubFriend/jquery.repeater
Complete Code : https://pastebin.com/iGgj7dty

<div class=”ggowl-outerlist” data-repeater-list=”ggowl_admin_options[ggowl_select_post_template_repeater]”>
<div class=”ggowl-repeater-item” data-repeater-item>
<div class=”field”>
<div class=”control”>
<div class=”select is-success”>
<select name=”” id=”ggowl_select_post_template_repeater”>
<option value=”page”>Page</option>
<option value=”post”>Post</option>
<option value=”custom”>Custom</option>
<option value=”Prodcut”>Audi</option>
</select>
</div></div></div>
<input class=”ggowl-delete-button” data-repeater-delete type=”button” value=”Delete”/>

<!– innner repeater –>
<div class=”inner-repeater”>
<div data-repeater-list=”inner-list”>
<div data-repeater-item>
<div class=”field”>
<div class=”control”>
<div class=”select is-success”>
<select name=”ggowl_admin_options[ggowl_select_post_template_repeater]” id=”ggowl_select_post_template_repeater”>
<option value=”volvo”>Volvo</option>
<option value=”saab”>Saab</option>
<option value=”mercedes”>Mercedes</option>
<option value=”audi”>Audi</option>
</select>
</div></div></div>
</div>
</div>
</div>

</div>
</div>
<input data-repeater-create type=”button” value=”Add”/>

Problem is if i set the data-repeater field as data-repeater-list=”ggowl_admin_options[ggowl_select_post_template_repeater]” it geneerates form with name=”ggowl_admin_options[ggowl_select_post_template_repeater][0][]”

But i will be only able to save if the name is ggowl_admin_options[ggowl_select_post_template_repeater]. But repeater generates a array

please help . Some reference to similar cases will be great if there.

Read more here:: How to save repeater fields in the options page?

Leave a Reply

Your email address will not be published. Required fields are marked *