webhook/webhook-cms — pull request #192 by liamjones (2014-12-16 22:10:03+00:00)
Title: Changed default generation logic so as to avoid generating known duplicate labels

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:

* Single line text
* Single line text 2
* Single line text 2
* Single line text 2

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?