humanmade/Custom-Meta-Boxes — pull request #46 by mattheu (2013-04-18 10:04:22+00:00)
Title: Better groups and repeatable

Repeatable anything got pretty buggy pretty fast.

Input name attributes used empty [] to create arrays of data. This is fine, until things start getting complex. It particularly caused problems when combining repeatable fields and groups.

This branch hopes to address this by explicitly setting [cmb-field-index] in the name attribute. Fields within groups are also given the group_index property. These values are then used for name & Id attributes.

Hidden fields are cloned from a hidden field with the index 'x', which is updated to the correct index when cloned. These hidden fields can then explicitly be removed before saving rather than just removing the last item - which was also causing issues.

I have made some fixes to the fields, and I think the only fields still with issues when repeatable are image and wysiwyg. I don't think the cause of these problems is directly related to this PR, so am leaving for now.

Backwards compatability should be 100%. The only issues I can see are with new fields created by devs, as I have switched to using a name_attr function to generate the name. I think it should be OK, but don't want to assume.