Skip to content

Commit

Permalink
Fix #43
Browse files Browse the repository at this point in the history
Replace all numbers from the beginning of the field name when creating
the form safe name
  • Loading branch information
Kenn Jacobsen committed Jul 20, 2016
1 parent 75f403e commit 5e0ac39
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/Solution/FormEditor/FieldHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace FormEditor
{
public static class FieldHelper
{
private static readonly Regex FormSafeNameRegex = new Regex("[^a-zA-Z0-9_]", RegexOptions.Compiled);
private static readonly Regex FormSafeNameRegex = new Regex(@"^\d*|[^a-zA-Z0-9_]", RegexOptions.Compiled);
public static string FormSafeName(string name)
{
return FormSafeNameRegex.Replace(name ?? string.Empty, "_");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
this.indexSafeFieldName = function (field) {
// lower case comparison and remove white spaces and other stuff
// - this must match the corresponding method for index safe field names in the C# code!
return field.name.replace(/[^a-z0-9-_]/gi, "");
return field.name.replace(/^\d*|[^a-zA-Z0-9_]/gi, "");
}
this.registerFields = function (allFields) {
this.fields = allFields;
Expand All @@ -21,7 +21,6 @@
if (field.name == null || field.name == "") {
return false;
}

var $this = this;
var fieldWithSameName = _.find(this.fields, function (f) {
return $this.isNamedField(f) && f != field && $this.indexSafeFieldName(f) == $this.indexSafeFieldName(field);
Expand Down

0 comments on commit 5e0ac39

Please sign in to comment.