Closed liamjones closed 9 years ago
After merging this in I took a closer look and decided to make a change because what we really want to compare against is the name
property. Thanks for your contribution and pointing out my non-functioning deduping logic. :+1:
https://github.com/webhook/webhook-cms/commit/84ab022439951d49a61de80f6f4274784de12a63
I noticed that, if you repeatedly added fields to a form without renaming them, then the default label generation logic was resulting in a list like:
Which prevents you from saving the form without making manual edits.
So, since it's a relatively small thing, I thought I'd take a crack at improving this myself rather than just bug reporting it.
Originally I just changed the filterBy() to look for labels which started with the default name but that could still result in dupes if you deleted fields from the middle of the list and then added another one. This is why it's now a bit more complicated. addControl() will look for the current highest numbered default field label and will add one to that number to generate its own default label.
The one thing this currently doesn't cope with is fields where you've completely deleted the label. Should you even be able to save a form where fields have no label though?