So I am trying to save a dynamically created set of fields to the database using $_POST
. Basically, I can't figure out how to get the options to save as an object for each fieldset instead of as an array of the options themselves. It's hard for me to describe... let me explain.
First, screenshot of what the thing looks like here.
The fields dynamically create via jQuery and that works great. Here's the fields I have set up for the form:
<label>Calendar Name
<input name="name[]" id="name[]" type="text" value="<?php echo $calendars['name'][$key]; ?>">
</label>
<label>Public URL
<input name="url[]" id="url[]" type="text" value="<?php echo $calendars['url'][$key]; ?>">
</label>
<label>Color
<input name="color[]" id="color[]" type="text" value="<?php echo $calendars['color'][$key]; ?>">
</label>
This is similar to this question but I guess I don't understand how I should be upping and sorting the index values properly using JS, or if there is a PHP solution I'm just completely missing.
TL;DR Basically how can I produce something like foo[0]['name'] instead of foo['name'][0] using either PHP or JS or both in a dynamically created form with repeating fieldsets?